Re: segfaults of processes while being killed after commit "mm: make the page fault mmap locking killable"

From: Oleg Nesterov
Date: Wed Jul 26 2023 - 05:30:28 EST


On 07/25, Linus Torvalds wrote:
>
> What exactly made you notice? Is it just the logging from
> 'show_unhandled_signals' being set?
>
> Because the actual signal itself, from the
>
> force_sig_fault(SIGSEGV, si_code, (void __user *)address);
>
> in __bad_area_nosemaphore() should be overridden by the fact that a
> lethal signal was already pending.

Yes, SIGSEGV won't be even delivered, prepare_signal() returns F if
SIGNAL_GROUP_EXIT is set.

> But let's add a couple of signal people rather than the mm people to
> the participants. Eric, Oleg - would not an existing fatal signal take
> precedence over a new SIGSEGV? I obviously thought it did, but looking
> at 'get_signal()' and the signal delivery, I don't actually see any
> code to that effect.

See

/* Has this task already been marked for death? */
if ((signal->flags & SIGNAL_GROUP_EXIT) ||
signal->group_exec_task) {
clear_siginfo(&ksig->info);
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;
}

in get_signal().

So yes, get_signal() returns SIGKILL if fatal_signal_pending() == T which
implies SIGNAL_GROUP_EXIT.

I think your patch is fine.

Oleg.