git: kernel - Fix signal / signal-mask-change race
Matthew Dillon
dillon at crater.dragonflybsd.org
Fri Nov 29 10:24:34 PST 2024
commit bbd7e13329c5bb82b8ee744e2c8780d994efbfbf
Author: Matthew Dillon <dillon at apollo.backplane.com>
Date: Fri Nov 29 10:16:53 2024 -0800
kernel - Fix signal / signal-mask-change race
* Fix race between incoming signals and sigsuspend(), ppoll(),
or pselect() when used to change the signal mask. A signal can
be received and queued to a process that is in the middle of
unmasking said signal without triggering signal processing.
* Our kernel *sleep*() and wakeup functions avoid whole-process
locks to ensure high thread performance, but this can result in
a race when a signal cannot be delivered to a thread and gets
queued to the process instead.
In order to keep the high-performance sleep, we instead use
atomic ops and a ref-counter only in code paths related to
general signal delivery to the process. Code which changes the
signal mask then waits for the ref-counter to become zero as
needed to ensure proper interlocked tests across signal mask
changes to close the race.
Summary of changes:
sys/kern/kern_sig.c | 34 ++++++++++++++++++++++++++++------
sys/kern/sys_generic.c | 5 +++++
sys/sys/proc.h | 3 ++-
sys/sys/signal2.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 85 insertions(+), 7 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/bbd7e13329c5bb82b8ee744e2c8780d994efbfbf
--
DragonFly BSD source repository
More information about the Commits
mailing list