Oleg Nesterov <o...@redhat.com> writes:

> sorry again for delay...
>
> On 02/07, Eric W. Biederman wrote:
>>
>> --- a/kernel/signal.c
>> +++ b/kernel/signal.c
>> @@ -2393,6 +2393,11 @@ bool get_signal(struct ksignal *ksig)
>>              goto relock;
>>      }
>>  
>> +    /* Has this task already been marked for death? */
>> +    ksig->info.si_signo = signr = SIGKILL;
>> +    if (signal_group_exit(signal))
>> +            goto fatal;
>> +
>>      for (;;) {
>>              struct k_sigaction *ka;
>>  
>> @@ -2488,6 +2493,7 @@ bool get_signal(struct ksignal *ksig)
>>                      continue;
>>              }
>>  
>> +    fatal:
>>              spin_unlock_irq(&sighand->siglock);
>
> Eric, but this is wrong. At least this is the serious user-visible
> change.
>
> Afaics, with this patch the tracee will never stop in PTRACE_EVENT_EXIT in 
> case
> of group_exit/exec, because schedule() in TASK_TRACED state won't block due to
> __fatal_signal_pending().
>
> Yes, yes, as I said many times the semantics of PTRACE_EVENT_EXIT was never 
> really
> defined, it depends on /dev/random, but still I don't think we should break 
> it even
> more.

Well it changes PTRACE_EVENT_EXIT I grant that.  It looks like that
changes makes PTRACE_EVENT_EXIT is less than useful.

The only way to perfectly preserve the previous semantics is probably to
do something like my JOBCTL_TASK_EXIT proposal.

That said I don't think even adding a JOBCTL_TASK_EXIT is enough to have
a reliable stop of ptrace_event_exit after a process has exited.  As any
other pending signal can cause problems there as well.

I have received a report that strace -f in some cases is not noticing
children before they die and it looks like a stop in PTRACE_EVENT_EXIT
would fix that strace behavior.

Sigh.

Here I was trying for the simple minimal change and I hit this landmine.
Which leaves me with the question of what should be semantics of signal
handling after exit.

I think from dim memory of previous conversations the desired semantics
look like:
a) Ignore all signal state except for SIGKILL.
b) Letting SIGKILL wake up the process should be sufficient.

I will see if I can reproduce the strace failure and see if I can cook
up something minimal that addresses just that.  If you have suggestions
I would love to hear them.

As this was a minimal fix for SIGKILL being broken I have already sent
the fix to Linus.  So we are looking at an incremental fix at this point.

Eric

Reply via email to