]> git.baikalelectronics.ru Git - kernel.git/commit
signal: Always notice exiting tasks
authorEric W. Biederman <ebiederm@xmission.com>
Thu, 7 Feb 2019 00:39:40 +0000 (18:39 -0600)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 7 Feb 2019 14:59:50 +0000 (08:59 -0600)
commitd491c7bd8ffcd9b2bcbbbc15be29d48bc39cd217
tree1782d141daf1fb0de74117125ab0965edd139241
parent33e85d2974c9d7e4df3bb4071c034d798947eec1
signal: Always notice exiting tasks

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: stable@vger.kernel.org
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
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" <ebiederm@xmission.com>
kernel/signal.c