|
@@ -2016,6 +2016,13 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
|
|
new_tsec->sid = old_tsec->exec_sid;
|
|
new_tsec->sid = old_tsec->exec_sid;
|
|
/* Reset exec SID on execve. */
|
|
/* Reset exec SID on execve. */
|
|
new_tsec->exec_sid = 0;
|
|
new_tsec->exec_sid = 0;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Minimize confusion: if no_new_privs and a transition is
|
|
|
|
+ * explicitly requested, then fail the exec.
|
|
|
|
+ */
|
|
|
|
+ if (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS)
|
|
|
|
+ return -EPERM;
|
|
} else {
|
|
} else {
|
|
/* Check for a default transition on this program. */
|
|
/* Check for a default transition on this program. */
|
|
rc = security_transition_sid(old_tsec->sid, isec->sid,
|
|
rc = security_transition_sid(old_tsec->sid, isec->sid,
|
|
@@ -2029,7 +2036,8 @@ static int selinux_bprm_set_creds(struct linux_binprm *bprm)
|
|
ad.selinux_audit_data = &sad;
|
|
ad.selinux_audit_data = &sad;
|
|
ad.u.path = bprm->file->f_path;
|
|
ad.u.path = bprm->file->f_path;
|
|
|
|
|
|
- if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)
|
|
|
|
|
|
+ if ((bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID) ||
|
|
|
|
+ (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS))
|
|
new_tsec->sid = old_tsec->sid;
|
|
new_tsec->sid = old_tsec->sid;
|
|
|
|
|
|
if (new_tsec->sid == old_tsec->sid) {
|
|
if (new_tsec->sid == old_tsec->sid) {
|