Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> writes: > On Wed, Oct 20, 2021 at 7:45 AM Eric W. Biederman <ebiederm@xxxxxxxxxxxx> wrote: >> >> Add a simple helper force_fatal_sig that causes a signal to be >> delivered to a process as if the signal handler was set to SIG_DFL. >> >> Reimplement force_sigsegv based upon this new helper. > > Can you just make the old force_sigsegv() go away? The odd special > casing of SIGSEGV was odd to begin with, I think everybody really just > wanted this new "force_fatal_sig()" and allow any signal - not making > SIGSEGV special. There remains the original case that is signal_set up_done deals with generically. When sending a signal fails the code attempts send SIGSEGV and if sending SIGSEGV fails the signal delivery code terminates the process with SIGSEGV. To keep dependencies to a minimum and to allow for the possibility of backports I used "force_sigsegv(SIGSEGV)" instead of "force_fatal_sig(SIGSEGV)". I will be happy to add an additional patch that converts all of those case to force_fatal_sig. > Also, I think it should set SIGKILL in p->pending.signal or something > like that - because we want this to trigger fatal_signal_pending(), > don't we? > > Right now fatal_signal_pending() is only true for SIGKILL, I think. In general when a fatal signal is delivered the function complete_signal individually delivers SIGKILL to the threads, making fatal_signal_pending true. For signals like SIGSYS that generate a coredump that is not currently true, but in the cases I looked at signal_pending() was enough to get the code to get_signal(), which dequeues the signals and starts processing them. I have a branch queued up for the next merge window that implements per signal_struct coredumps. Assuming that does not trigger any user space regressions I can remove the coredump special case in complete_signal. That will in turn mean that force_siginfo_to_task does not need to change sa_handler, blocked or clear SIGNAL_UNKILLABLE, as all of the cases where that matters today will just wind up with complete_signal setting a per_thread SIGKILL. I keep playing with the idea of having fatal_signal_pending depend on a different flag than the per thread bit for SIGKILL in the per thread signal set. That might make it clearer that complete_signal has started killing the process and it is a start of the killing the process that triggers fatal_signal_pending. So far the way fatal_signal_pending works hasn't really been a problem so I keep putting away ideas of cleaner implementations. Eric