Skip to content

Commit 6834e0b

Browse files
committed
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 <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 8890b29 commit 6834e0b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

fs/exec.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,11 @@ int begin_new_exec(struct linux_binprm * bprm)
13041304
struct task_struct *me = current;
13051305
int retval;
13061306

1307+
/*
1308+
* Ensure all future errors are fatal.
1309+
*/
1310+
bprm->point_of_no_return = true;
1311+
13071312
/*
13081313
* Make this the only thread in the thread group.
13091314
*/
@@ -1326,13 +1331,6 @@ int begin_new_exec(struct linux_binprm * bprm)
13261331
if (retval)
13271332
goto out;
13281333

1329-
/*
1330-
* With the new mm installed it is completely impossible to
1331-
* fail and return to the original process. If anything from
1332-
* here on returns an error, the check in __do_execve_file()
1333-
* will SEGV current.
1334-
*/
1335-
bprm->point_of_no_return = true;
13361334
bprm->mm = NULL;
13371335

13381336
#ifdef CONFIG_POSIX_TIMERS

0 commit comments

Comments
 (0)