[PATCH 05/17] signal: Bring down all threads when handling a non-coredump fatal signal

From: Eric W. Biederman
Date: Wed Jun 19 2024 - 00:07:18 EST



For non-coredump fatal signals instead of dropping and reacquiring
siglock to shoot down the other threads from do_group_exit
at the end of get_signal, shot down the other threads before
siglock is dropped.

This can not be done for coredump signals yet, because do_coredump
needs to be in a position to catch dying threads before it kills them
so it can make certain to catch them, so they can be added to the
coredump.

Signed-off-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
---
kernel/signal.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index caeaff81a197..269ec88f650d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2882,7 +2882,13 @@ bool get_signal(struct ksignal *ksig)
* Anything else is fatal, maybe with a core dump.
*/
exit_code = signr;
- group_exit_needed = true;
+ if (sig_kernel_coredump(signr))
+ group_exit_needed = true;
+ else {
+ signal->group_exit_code = exit_code;
+ signal->flags = SIGNAL_GROUP_EXIT;
+ zap_other_threads(current);
+ }
fatal:
spin_unlock_irq(&sighand->siglock);
if (unlikely(cgroup_task_frozen(current)))
--
2.41.0