[PATCH 1/2] signal: factor out SIGKILL generation in get_signal

From: Kyle Huey
Date: Sun Oct 31 2021 - 23:44:13 EST


In preparation for adding a second case that will invoke the same code,
factor out this branch. Fix label formatting while we're nearby too.

Signed-off-by: Kyle Huey <khuey@xxxxxxxxxxxx>
Reported-by: Marko Mäkelä <marko.makela@xxxxxxxxxxx>
---
kernel/signal.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 487bf4f5dadf..4d26ee5c662a 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2690,12 +2690,7 @@ bool get_signal(struct ksignal *ksig)

/* Has this task already been marked for death? */
if (signal_group_exit(signal)) {
- ksig->info.si_signo = signr = SIGKILL;
- sigdelset(&current->pending.signal, SIGKILL);
- trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO,
- &sighand->action[SIGKILL - 1]);
- recalc_sigpending();
- goto fatal;
+ goto kill;
}

for (;;) {
@@ -2816,7 +2811,16 @@ bool get_signal(struct ksignal *ksig)
continue;
}

- fatal:
+ goto fatal;
+
+kill:
+ ksig->info.si_signo = signr = SIGKILL;
+ sigdelset(&current->pending.signal, SIGKILL);
+ trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO,
+ &sighand->action[SIGKILL - 1]);
+ recalc_sigpending();
+
+fatal:
spin_unlock_irq(&sighand->siglock);
if (unlikely(cgroup_task_frozen(current)))
cgroup_leave_frozen(true);
--
2.33.1