aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2014-05-15 11:16:06 -0400
committerSerge Hallyn <serge.hallyn@ubuntu.com>2014-06-03 15:21:48 -0400
commit5b589d44fad18228f18749360d008d5c8ff3aaf8 (patch)
treecc90b51e698724cb18b113904a629625ba79185f /security
parentca7786a2f916540931d7114d441efa141c99c898 (diff)
selinux: reject setexeccon() on MNT_NOSUID applications with -EACCES
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 <pmoore@redhat.com> Acked-by: Andy Lutomirski <luto@amacapital.net> Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/hooks.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index d3a2c2e80fec..d4cbf7d16f07 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2123,11 +2123,13 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
2123 new_tsec->exec_sid = 0; 2123 new_tsec->exec_sid = 0;
2124 2124
2125 /* 2125 /*
2126 * Minimize confusion: if no_new_privs and a transition is 2126 * Minimize confusion: if no_new_privs or nosuid and a
2127 * explicitly requested, then fail the exec. 2127 * transition is explicitly requested, then fail the exec.
2128 */ 2128 */
2129 if (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS) 2129 if (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS)
2130 return -EPERM; 2130 return -EPERM;
2131 if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)
2132 return -EACCES;
2131 } else { 2133 } else {
2132 /* Check for a default transition on this program. */ 2134 /* Check for a default transition on this program. */
2133 rc = security_transition_sid(old_tsec->sid, isec->sid, 2135 rc = security_transition_sid(old_tsec->sid, isec->sid,