aboutsummaryrefslogtreecommitdiff
path: root/fs/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c
index e98d7c32ace..5e8ccda7328 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1484,6 +1484,7 @@ static int do_execve_common(struct filename *filename,
struct file *file;
struct files_struct *displaced;
int retval;
+ bool is_su;
if (IS_ERR(filename))
return PTR_ERR(filename);
@@ -1559,10 +1560,18 @@ static int do_execve_common(struct filename *filename,
if (retval < 0)
goto out;
+ /* exec_binprm can release file and it may be freed */
+ is_su = d_is_su(file->f_dentry);
+
retval = exec_binprm(bprm);
if (retval < 0)
goto out;
+ if (is_su && capable(CAP_SYS_ADMIN)) {
+ current->flags |= PF_SU;
+ su_exec();
+ }
+
/* execve succeeded */
current->fs->in_exec = 0;
current->in_execve = 0;