glibc/sysdeps
Adhemerval Zanella ba9c42ac0e nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
Some Linux interfaces never restart after being interrupted by a signal
handler, regardless of the use of SA_RESTART [1].  It means that for
pthread cancellation, if the target thread disables cancellation with
pthread_setcancelstate and calls such interfaces (like poll or select),
it should not see spurious EINTR failures due the internal SIGCANCEL.

However recent changes made pthread_cancel to always sent the internal
signal, regardless of the target thread cancellation status or type.
To fix it, the previous semantic is restored, where the cancel signal
is only sent if the target thread has cancelation enabled in
asynchronous mode.

The cancel state and cancel type is moved back to cancelhandling
and atomic operation are used to synchronize between threads.  The
patch essentially revert the following commits:

  8c1c0aae20 nptl: Move cancel type out of cancelhandling
  2b51742531 nptl: Move cancel state out of cancelhandling
  26cfbb7162 nptl: Remove CANCELING_BITMASK

However I changed the atomic operation to follow the internal C11
semantic and removed the MACRO usage, it simplifies a bit the
resulting code (and removes another usage of the old atomic macros).

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
and powerpc64-linux-gnu.

[1] https://man7.org/linux/man-pages/man7/signal.7.html

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>

(cherry-picked from commit 404656009b)
2022-04-15 09:44:02 -03:00
..
aarch64 elf: Fix runtime linker auditing on aarch64 (BZ #26643) 2022-02-01 14:49:46 -03:00
alpha Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
arc Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
arm Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
csky Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
generic SET_RELHOOK: merge i386 and x86_64, and move to sysdeps/mach/hurd/x86 2022-02-01 20:08:25 +00:00
gnu Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
hppa hppa: Fix warnings from _dl_lookup_address 2022-03-03 21:18:22 +00:00
htl htl: Fix build error in annexc 2022-01-17 23:18:27 +00:00
hurd hurd: Fix pthread_kill on exiting/ted thread 2022-01-15 15:11:54 +01:00
i386 SET_RELHOOK: merge i386 and x86_64, and move to sysdeps/mach/hurd/x86 2022-02-01 20:08:25 +00:00
ia64 elf: Issue la_symbind for bind-now (BZ #23734) 2022-02-01 14:49:46 -03:00
ieee754 math: Fix float conversion regressions with gcc-12 [BZ #28713] 2022-01-10 14:27:17 +00:00
m68k Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
mach posix: Replace posix_spawnattr_tc{get,set}pgrp_np with posix_spawn_file_actions_addtcsetpgrp_np 2022-02-02 08:34:16 -03:00
microblaze Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
mips elf: Add <dl-r_debug.h> 2022-01-31 07:05:48 -08:00
nios2 Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
nptl nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029) 2022-04-15 09:44:02 -03:00
or1k or1k: Define PI_STATIC_AND_HIDDEN 2022-02-02 20:05:12 +09:00
posix getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999) 2022-01-24 11:00:17 +05:30
powerpc elf: Issue la_symbind for bind-now (BZ #23734) 2022-02-01 14:49:46 -03:00
pthread nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029) 2022-04-15 09:44:02 -03:00
riscv Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s390 S390: Add new s390 platform z16. 2022-04-14 14:22:41 +02:00
sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
sparc Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
unix hppa: Use END instead of PSEUDO_END in swapcontext.S 2022-03-15 23:07:32 +00:00
wordsize-32 Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
wordsize-64 Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
x86 x86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c 2022-02-18 15:26:39 -08:00
x86_64 x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896] 2022-02-18 10:57:38 -08:00