Re: siginfo pid not populated from ptrace?

From: Oleg Nesterov
Date: Mon Dec 10 2018 - 09:57:22 EST


On 12/06, Tycho Andersen wrote:
>
> --- 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) ||
^^^^^^^^^^^^^^

task_is_traced() checks task->state, probably you meant t->ptrace != 0.

However, in multithreaded case t->ptrace won't help too, unless the signal
is private you do not know which thread will actually dequeue this signal
and possibly report to debugger.

Oleg.