]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
exec: Set the point of no return sooner
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 4 Apr 2020 17:01:37 +0000 (12:01 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Mon, 11 May 2020 17:08:49 +0000 (12:08 -0500)
Make the code more robust by marking the point of no return sooner.
This ensures that future code changes don't need to worry about how
they return errors if they are past this point.

This results in no actual change in behavior as __do_execve_file does
not force SIGSEGV when there is a pending fatal signal pending past
the point of no return.  Further the only error returns from de_thread
and exec_mmap that can occur result in fatal signals being pending.

Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/87sgga5klu.fsf_-_@x220.int.ebiederm.org
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
fs/exec.c

index fa265ea322b71a7a74a2cb36d2b6aca40a5d0b9f..9aa08ce2ffccf59cf14874466e60c6b87b239d05 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1304,6 +1304,11 @@ int begin_new_exec(struct linux_binprm * bprm)
        struct task_struct *me = current;
        int retval;
 
+       /*
+        * Ensure all future errors are fatal.
+        */
+       bprm->point_of_no_return = true;
+
        /*
         * Make this the only thread in the thread group.
         */
@@ -1326,13 +1331,6 @@ int begin_new_exec(struct linux_binprm * bprm)
        if (retval)
                goto out;
 
-       /*
-        * With the new mm installed it is completely impossible to
-        * fail and return to the original process.  If anything from
-        * here on returns an error, the check in __do_execve_file()
-        * will SEGV current.
-        */
-       bprm->point_of_no_return = true;
        bprm->mm = NULL;
 
 #ifdef CONFIG_POSIX_TIMERS