[PATCH 2/2] signal: after notifying a ptracer of a signal, recheck for pending SIGKILLs
From: Kyle Huey
Date: Sun Oct 31 2021 - 23:44:18 EST
ptrace_signal will release the siglock which could result in the current
task catching a SIGKILL that was not present on our first check in
get_signal. If that happens, bail out of the current signal and go
straight to the SIGKILL. This avoids setting up a frame for a signal
that the ptracer may not be notified of but that will be visible at
PTRACE_EVENT_EXIT.
Signed-off-by: Kyle Huey <khuey@xxxxxxxxxxxx>
Reported-by: Marko Mäkelä <marko.makela@xxxxxxxxxxx>
---
kernel/signal.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/signal.c b/kernel/signal.c
index 4d26ee5c662a..09810777c61b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2738,6 +2738,13 @@ bool get_signal(struct ksignal *ksig)
signr = ptrace_signal(signr, &ksig->info);
if (!signr)
continue;
+ /*
+ * After calling the debugger anything could have changed.
+ * If there's a pending SIGKILL stop processing the current
+ * signal and skip straight to the end.
+ */
+ if (signal_group_exit(signal))
+ goto kill;
}
ka = &sighand->action[signr-1];
--
2.33.1