Skip to content

Commit

Permalink
selinux: fix non-MLS handling in mls_context_to_sid()
Browse files Browse the repository at this point in the history
Commit 95ffe19 ("selinux: refactor mls_context_to_sid() and make
it stricter") inadvertently changed how we handle labels that did not
contain MLS information.  This patch restores the proper behavior in
mls_context_to_sid() and adds a comment explaining the proper
behavior to help ensure this doesn't happen again.

Fixes: 95ffe19 ("selinux: refactor mls_context_to_sid() and make it stricter")
Reported-by: Stephen Smalley <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
pcmoore committed Nov 14, 2018
1 parent c138325 commit 877181a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions security/selinux/ss/mls.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,13 @@ int mls_context_to_sid(struct policydb *pol,
char *rangep[2];

if (!pol->mls_enabled) {
if ((def_sid != SECSID_NULL && oldc) || (*scontext) == '\0')
return 0;
return -EINVAL;
/*
* With no MLS, only return -EINVAL if there is a MLS field
* and it did not come from an xattr.
*/
if (oldc && def_sid == SECSID_NULL)
return -EINVAL;
return 0;
}

/*
Expand Down

0 comments on commit 877181a

Please sign in to comment.