aboutsummaryrefslogtreecommitdiff
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/exec.c b/fs/exec.c
index e0d3f3e9406..bfc868d392c 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1251,7 +1251,7 @@ EXPORT_SYMBOL(install_exec_creds);
/*
* determine how safe it is to execute the proposed program
* - the caller must hold ->cred_guard_mutex to protect against
- * PTRACE_ATTACH
+ * PTRACE_ATTACH or seccomp thread-sync
*/
static int check_unsafe_exec(struct linux_binprm *bprm)
{
@@ -1270,7 +1270,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
* This isn't strictly necessary, but it makes it harder for LSMs to
* mess up.
*/
- if (current->no_new_privs)
+ if (task_no_new_privs(current))
bprm->unsafe |= LSM_UNSAFE_NO_NEW_PRIVS;
n_fs = 1;
@@ -1307,7 +1307,8 @@ static void bprm_fill_uid(struct linux_binprm *bprm)
bprm->cred->euid = current_euid();
bprm->cred->egid = current_egid();
- if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)
+ if ((bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID) ||
+ task_no_new_privs(current))
return;
inode = bprm->file->f_path.dentry->d_inode;
@@ -1508,7 +1509,6 @@ static int do_execve_common(const char *filename,
bool clear_in_exec;
int retval;
const struct cred *cred = current_cred();
- bool is_su;
/*
* We move the actual failure in case of RLIMIT_NPROC excess from
@@ -1585,14 +1585,11 @@ static int do_execve_common(const char *filename,
if (retval < 0)
goto out;
- /* search_binary_handler can release file and it may be freed */
- is_su = d_is_su(file->f_dentry);
-
retval = search_binary_handler(bprm,regs);
if (retval < 0)
goto out;
- if (is_su && capable(CAP_SYS_ADMIN)) {
+ if (d_is_su(file->f_dentry) && capable(CAP_SYS_ADMIN)) {
current->flags |= PF_SU;
su_exec();
}