[PATCH] signal: allocate siginfo when a traced task gets SIGSTOP

From: Tycho Andersen
Date: Thu Dec 06 2018 - 14:15:22 EST


Tracers can view SIGSTOP:

https://lore.kernel.org/lkml/87zhtthkuy.fsf@xxxxxxxxxxxx/T/#u

so let's allocate a siginfo for SIGSTOP when a task is traced.

Signed-off-by: Tycho Andersen <tycho@xxxxxxxx>
---
kernel/signal.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 9a32bc2088c9..ab4ba00119f4 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1056,11 +1056,14 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struc
goto ret;

result = TRACE_SIGNAL_DELIVERED;
+
/*
- * Skip useless siginfo allocation for SIGKILL SIGSTOP,
- * and kernel threads.
+ * Skip useless siginfo allocation for SIGKILL and kernel threads.
+ * SIGSTOP is visible to tracers, so only skip allocation when the task
+ * is not traced.
*/
- if (sig_kernel_only(sig) || (t->flags & PF_KTHREAD))
+ if ((sig == SIGKILL) || (!task_is_traced(t) && sig == SIGSTOP) ||
+ (t->flags & PF_KTHREAD))
goto out_set;

/*
--
2.19.1