WSL2-Linux-Kernel/include
Oleg Nesterov e6fa16ab9c signal: sigprocmask() should do retarget_shared_pending()
In short, almost every changing of current->blocked is wrong, or at least
can lead to the unexpected results.

For example. Two threads T1 and T2, T1 sleeps in sigtimedwait/pause/etc.
kill(tgid, SIG) can pick T2 for TIF_SIGPENDING. If T2 calls sigprocmask()
and blocks SIG before it notices the pending signal, nobody else can handle
this pending shared signal.

I am not sure this is bug, but at least this looks strange imho. T1 should
not sleep forever, there is a signal which should wake it up.

This patch moves the code which actually changes ->blocked into the new
helper, set_current_blocked() and changes this code to call
retarget_shared_pending() as exit_signals() does. We should only care about
the signals we just blocked, we use "newset & ~current->blocked" as a mask.

We do not check !sigisemptyset(newblocked), retarget_shared_pending() is
cheap unless mask & shared_pending.

Note: for this particular case we could simply change sigprocmask() to
return -EINTR if signal_pending(), but then we should change other callers
and, more importantly, if we need this fix then set_current_blocked() will
have more callers and some of them can't restart. See the next patch as a
random example.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Matt Fleming <matt.fleming@linux.intel.com>
Acked-by: Tejun Heo <tj@kernel.org>
2011-04-28 13:01:37 +02:00
..
acpi Merge branch 'linus' into release 2011-03-23 02:34:54 -04:00
asm-generic WARN_ON_SMP(): Add comment to explain ({0;}) 2011-03-28 10:10:42 -04:00
crypto
drm drm: fix "persistant" typo 2011-04-05 10:22:23 +10:00
keys libceph: Create a new key type "ceph". 2011-03-29 12:11:24 -07:00
linux signal: sigprocmask() should do retarget_shared_pending() 2011-04-28 13:01:37 +02:00
math-emu
media [media] videobuf2-dma-contig: make cookie() return a pointer to dma_addr_t 2011-03-22 19:41:58 -03:00
mtd
net sctp: fix auth_hmacs field's length of struct sctp_cookie 2011-04-01 21:45:50 -07:00
pcmcia
rdma
rxrpc
scsi [SCSI] libiscsi_tcp: use kmap in xmit path 2011-03-23 11:36:58 -05:00
sound Merge branch 'for-2.6.39' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6 into fix/asoc 2011-03-28 13:02:29 +02:00
staging [media] Altera FPGA firmware download module 2011-03-21 20:32:16 -03:00
target [SCSI] target: add initial statistics 2011-03-23 11:36:50 -05:00
trace Merge branch 'for-linus-unmerged' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable 2011-03-28 15:31:05 -07:00
video atmel_lcdfb: implement inverted contrast pwm 2011-03-22 16:23:44 +09:00
xen Merge branch 'stable/xen.pm.bug-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2011-03-17 18:37:42 -07:00
Kbuild