2019-04-20 10:45:17

by weizhenliang

[permalink] [raw]
Subject: [PATCH] signal: trace_signal_deliver when signal_group_exit

In the following commit, removing SIGKILL from each thread signal mask
and executing "goto fatal" directly will skip the call to
"trace_signal_deliver". At this point, the delivery tracking of the SIGKILL
signal will be inaccurate.

commit cf43a757fd4944 ("signal: Restore the stop PTRACE_EVENT_EXIT")

Therefore, we need to add trace_signal_deliver before "goto fatal"
after executing sigdelset.

Signed-off-by: Zhenliang Wei <[email protected]>
---
kernel/signal.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/signal.c b/kernel/signal.c
index 227ba170298e..439b742e3229 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2441,6 +2441,8 @@ bool get_signal(struct ksignal *ksig)
if (signal_group_exit(signal)) {
ksig->info.si_signo = signr = SIGKILL;
sigdelset(&current->pending.signal, SIGKILL);
+ trace_signal_deliver(signr, &ksig->info,
+ &sighand->action[signr - 1]);
recalc_sigpending();
goto fatal;
}
--
2.14.1.windows.1



2019-04-20 11:23:38

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [PATCH] signal: trace_signal_deliver when signal_group_exit

On 04/20, Zhenliang Wei wrote:
>
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2441,6 +2441,8 @@ bool get_signal(struct ksignal *ksig)
> if (signal_group_exit(signal)) {
> ksig->info.si_signo = signr = SIGKILL;
> sigdelset(&current->pending.signal, SIGKILL);
> + trace_signal_deliver(signr, &ksig->info,
> + &sighand->action[signr - 1]);

Well, in this case ksig->info is not fully initialized for TP_STORE_SIGINFO()
which reads si_errno/si_code...

How about

trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, SIG_DFL)

?

We know that action[SIGKILL] must be SIG_DFL.

And SEND_SIG_NOINFO matches the fact that SIGKILL doesn't have any info,
collect_signal() sets SI_USER and clears si_errno in this case.

Oleg.

2019-04-22 02:42:33

by weizhenliang

[permalink] [raw]
Subject: RE: [PATCH] signal: trace_signal_deliver when signal_group_exit

On 04/20, Oleg Nesterov wrote:
>On 04/20, Zhenliang Wei wrote:
>>
>> --- a/kernel/signal.c
>> +++ b/kernel/signal.c
>> @@ -2441,6 +2441,8 @@ bool get_signal(struct ksignal *ksig)
>> if (signal_group_exit(signal)) {
>> ksig->info.si_signo = signr = SIGKILL;
>> sigdelset(&current->pending.signal, SIGKILL);
>> + trace_signal_deliver(signr, &ksig->info,
>> + &sighand->action[signr - 1]);
>
>Well, in this case ksig->info is not fully initialized for TP_STORE_SIGINFO() which reads si_errno/si_code...
>
>How about
>
> trace_signal_deliver(SIGKILL, SEND_SIG_NOINFO, SIG_DFL)
>
>?
>
>We know that action[SIGKILL] must be SIG_DFL.
>
>And SEND_SIG_NOINFO matches the fact that SIGKILL doesn't have any info,
>collect_signal() sets SI_USER and clears si_errno in this case.
>
>Oleg.

Thank you for your review, I agree with your suggestion, and I will recommit the patch later.

Zhenliang Wei.