Skip to content

Commit 7673bf5

Browse files
committed
fork: Unconditionally exit if a fatal signal is pending
In practice this does not change anything as testing for fatal_signal_pending and exiting for with an error code duplicates the work of the next clause which recalculates pending signals and then exits fork if any are pending. In both cases the pending signal will trigger the slow path when existing to userspace, and the fatal signal will cause do_exit to be called. The advantage of making this a separate test is that it makes it clear processing the fatal signal will terminate the fork, and it allows the rest of the signal logic to be updated without fear that this important case will be lost. Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 4ca1d3e commit 7673bf5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/fork.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,12 @@ static __latent_entropy struct task_struct *copy_process(
19281928
goto bad_fork_cancel_cgroup;
19291929
}
19301930

1931+
/* Let kill terminate clone/fork in the middle */
1932+
if (fatal_signal_pending(current)) {
1933+
retval = -EINTR;
1934+
goto bad_fork_cancel_cgroup;
1935+
}
1936+
19311937
/*
19321938
* Process group and session signals need to be delivered to just the
19331939
* parent before the fork or both the parent and the child after the

0 commit comments

Comments
 (0)