exec: Add comments on check_unsafe_exec() fs counting
Subsystems (2)
PATCH 1/1 exec: Add comments on check_unsafe_exec() fs counting
Add some comments about what the fs counting is doing in check_unsafe_exec() and how it relates to the call graph. Specifically, we can't force an unshare of the fs because of at least Chrome:
https://lore.kernel.org/lkml/[email protected]/
Cc Eric Biederman <[email protected]>
Signed-off-by Kees Cook <[email protected]>
--- fs/exec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/exec.c +12 -0
@@ -1571,6 +1571,12 @@ static void check_unsafe_exec(struct linux_binprm *bprm)if (task_no_new_privs (current)) bprm->unsafe |=LSM_UNSAFE_NO_NEW_PRIVS ; +/* +* If another task is sharing our fs, we cannot safely +* suid exec because the differently privileged task +* will be able to manipulate the current directory, etc. +* It would be nice to force an unshare instead... +*/ t = p; n_fs =1 ;spin_lock (&p->fs->lock);
@@ -1752,6 +1758,7 @@ static int search_binary_handler(struct linux_binprm *bprm)return retval; } +/* binfmt handlers will call back into begin_new_exec() on success. */ static int exec_binprm (struct linux_binprm *bprm) {pid_t old_pid, old_vpid;
@@ -1810,6 +1817,11 @@ static int bprm_execve(struct linux_binprm *bprm,if (retval)return retval; +/* +* Check for unsafe execution states before exec_binprm(), which +* will call back into begin_new_exec(), into bprm_creds_from_file(), +* where setuid-ness is evaluated. +*/ check_unsafe_exec (bprm); current->in_execve =1 ;
Signature · 1 line
2.34.1
Quoted 10 lines · Kees Cook
Add some comments about what the fs counting is doing in
check_unsafe_exec()and how it relates to the call graph. Specifically, we can't force an unshare of the fs because of at least Chrome:
https://lore.kernel.org/lkml/[email protected]/Cc Eric Biederman <[email protected]>Signed-off-by Kees Cook <[email protected]>---