File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1573,6 +1573,12 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
15731573 if (task_no_new_privs (current ))
15741574 bprm -> unsafe |= LSM_UNSAFE_NO_NEW_PRIVS ;
15751575
1576+ /*
1577+ * If another task is sharing our fs, we cannot safely
1578+ * suid exec because the differently privileged task
1579+ * will be able to manipulate the current directory, etc.
1580+ * It would be nice to force an unshare instead...
1581+ */
15761582 t = p ;
15771583 n_fs = 1 ;
15781584 spin_lock (& p -> fs -> lock );
@@ -1753,6 +1759,7 @@ static int search_binary_handler(struct linux_binprm *bprm)
17531759 return retval ;
17541760}
17551761
1762+ /* binfmt handlers will call back into begin_new_exec() on success. */
17561763static int exec_binprm (struct linux_binprm * bprm )
17571764{
17581765 pid_t old_pid , old_vpid ;
@@ -1811,6 +1818,11 @@ static int bprm_execve(struct linux_binprm *bprm,
18111818 if (retval )
18121819 return retval ;
18131820
1821+ /*
1822+ * Check for unsafe execution states before exec_binprm(), which
1823+ * will call back into begin_new_exec(), into bprm_creds_from_file(),
1824+ * where setuid-ness is evaluated.
1825+ */
18141826 check_unsafe_exec (bprm );
18151827 current -> in_execve = 1 ;
18161828
You can’t perform that action at this time.
0 commit comments