Skip to content

Commit

Permalink
signal: Always notice exiting tasks
Browse files Browse the repository at this point in the history
commit 35634ffa1751b6efd8cf75010b509dcb0263e29b upstream.

Recently syzkaller was able to create unkillablle processes by
creating a timer that is delivered as a thread local signal on SIGHUP,
and receiving SIGHUP SA_NODEFERER.  Ultimately causing a loop
failing to deliver SIGHUP but always trying.

Upon examination it turns out part of the problem is actually most of
the solution.  Since 2.5 signal delivery has found all fatal signals,
marked the signal group for death, and queued SIGKILL in every threads
thread queue relying on signal->group_exit_code to preserve the
information of which was the actual fatal signal.

The conversion of all fatal signals to SIGKILL results in the
synchronous signal heuristic in next_signal kicking in and preferring
SIGHUP to SIGKILL.  Which is especially problematic as all
fatal signals have already been transformed into SIGKILL.

Instead of dequeueing signals and depending upon SIGKILL to
be the first signal dequeued, first test if the signal group
has already been marked for death.  This guarantees that
nothing in the signal queue can prevent a process that needs
to exit from exiting.

Cc: [email protected]
Tested-by: Dmitry Vyukov <[email protected]>
Reported-by: Dmitry Vyukov <[email protected]>
Ref: ebf5ebe31d2c ("[PATCH] signal-fixes-2.5.59-A4")
History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
Signed-off-by: "Eric W. Biederman" <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ebiederm authored and gregkh committed Feb 15, 2019
1 parent 80aec98 commit 39beaea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,11 @@ int 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;

Expand Down Expand Up @@ -2293,6 +2298,7 @@ int get_signal(struct ksignal *ksig)
continue;
}

fatal:
spin_unlock_irq(&sighand->siglock);

/*
Expand Down

0 comments on commit 39beaea

Please sign in to comment.