about summary refs log tree commit diff
path: root/sysdeps/htl/pthreadP.h
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-07-31 12:44:37 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-06-19 09:05:43 -0300
commit80f34f5173a29833c4f9e73a9725376448769a99 (patch)
tree4f14d07fe9a9d5c677818d23bda45f9288a5b02d /sysdeps/htl/pthreadP.h
parentc49e66c7e507f2d37c4725ce4680f19179cfa44e (diff)
downloadglibc-80f34f5173a29833c4f9e73a9725376448769a99.tar.gz
glibc-80f34f5173a29833c4f9e73a9725376448769a99.tar.xz
glibc-80f34f5173a29833c4f9e73a9725376448769a99.zip
stdlib: Make abort AS-safe (BZ 26275) azanella/bz26275-abort-as
The recursive lock used on abort does not synchronize with new
process creation (either by fork-like interfaces or posix_spawn
ones), nor it is reinitialized after fork.

Also, the SIGABRT unblock before raise shows another race-condition,
where a fork or posix_spawn call by another thread just after
the recursive lock release and before the SIGABRT raise might create
programs with a non-expected signal mask.

To fix the AS-safe, the raise is issues without changing the process
signal mask, and an AS-safe lock is used if a SIGABRT is installed or
the process is blocked or ignored.  The the signal mask change removal,
there is no need to use a recursive lock.  The lock is also on
both _Fork and posix_spawn, to avoid the spawn process to see the
abort handler as SIG_DFL.

The posix_spawn possible issue is if caller sets a SIG_IGN for
SIGABRT, calls abort, and another thread issues posix_spawn just
after the sigaction returns.  With default options (not setting
POSIX_SPAWN_SETSIGDEF), the process can still see SIG_DFL for
SIGABRT, where it should be SIG_IGN.

The fallback is also simplified, there is no nned to use a loop of
ABORT_INSTRUCTION after _exit (if the syscall does not terminate the
process, the system is really broken).

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Diffstat (limited to 'sysdeps/htl/pthreadP.h')
-rw-r--r--sysdeps/htl/pthreadP.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h
index cf8a2efe86..b0c9ceb23a 100644
--- a/sysdeps/htl/pthreadP.h
+++ b/sysdeps/htl/pthreadP.h
@@ -92,6 +92,8 @@ int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
 int __pthread_attr_getstack (const pthread_attr_t *, void **, size_t *);
 void __pthread_testcancel (void);
 
+#define __pthread_raise_internal(__sig) raise (__sig)
+
 libc_hidden_proto (__pthread_self)
 
 #if IS_IN (libpthread)