Skip to content

Commit

Permalink
selinux: reject setexeccon() on MNT_NOSUID applications with -EACCES
Browse files Browse the repository at this point in the history
We presently prevent processes from using setexecon() to set the
security label of exec()'d processes when NO_NEW_PRIVS is enabled by
returning an error; however, we silently ignore setexeccon() when
exec()'ing from a nosuid mounted filesystem.  This patch makes things
a bit more consistent by returning an error in the setexeccon()/nosuid
case.

Signed-off-by: Paul Moore <[email protected]>
Acked-by: Andy Lutomirski <[email protected]>
Acked-by: Stephen Smalley <[email protected]>
  • Loading branch information
pcmoore authored and hallyn committed Jun 3, 2014
1 parent ca7786a commit 5b589d4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,11 +2123,13 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
new_tsec->exec_sid = 0;

/*
* Minimize confusion: if no_new_privs and a transition is
* explicitly requested, then fail the exec.
* Minimize confusion: if no_new_privs or nosuid and a
* transition is explicitly requested, then fail the exec.
*/
if (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS)
return -EPERM;
if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)
return -EACCES;
} else {
/* Check for a default transition on this program. */
rc = security_transition_sid(old_tsec->sid, isec->sid,
Expand Down

0 comments on commit 5b589d4

Please sign in to comment.