summaryrefslogtreecommitdiff
path: root/fs/exec.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2020-04-04 12:01:37 -0500
committerEric W. Biederman <ebiederm@xmission.com>2020-05-11 12:08:49 -0500
commit6834e0bb41bbe144d42b8cd843f3ee30bfe2c825 (patch)
tree5b6a67f79400fd6868e5debdc16dfa1811f40225 /fs/exec.c
parent8890b29341f30f4a364b2eb6046bb1ac1478f955 (diff)
exec: Set the point of no return sooner
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>
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/exec.c b/fs/exec.c
index fa265ea322b7..9aa08ce2ffcc 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1305,6 +1305,11 @@ int begin_new_exec(struct linux_binprm * bprm)
int retval;
/*
+ * Ensure all future errors are fatal.
+ */
+ bprm->point_of_no_return = true;
+
+ /*
* Make this the only thread in the thread group.
*/
retval = de_thread(me);
@@ -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