aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/nptl
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2024-09-28 09:44:25 +0200
committerFlorian Weimer <fweimer@redhat.com>2024-09-28 09:44:25 +0200
commitb300078d97a6892cb2fa1c63a46333754db60555 (patch)
tree5d6b41dde73905895cf43a7957f9512f9e8e4372 /sysdeps/nptl
parenta7b5eb821d48b0cb14d0c0d2706410d4f7838cf6 (diff)
downloadglibc-b300078d97a6892cb2fa1c63a46333754db60555.zip
glibc-b300078d97a6892cb2fa1c63a46333754db60555.tar.gz
glibc-b300078d97a6892cb2fa1c63a46333754db60555.tar.bz2
Linux: Block signals around _Fork (bug 32215)
This hides the inconsistent TCB state (missing robust mutex list) from signal handlers. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/nptl')
-rw-r--r--sysdeps/nptl/_Fork.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/nptl/_Fork.c b/sysdeps/nptl/_Fork.c
index ef199dd..fd2cfc7 100644
--- a/sysdeps/nptl/_Fork.c
+++ b/sysdeps/nptl/_Fork.c
@@ -22,6 +22,11 @@
pid_t
_Fork (void)
{
+ /* Block all signals to avoid revealing the inconsistent TCB state
+ to a signal handler after fork. */
+ internal_sigset_t original_sigmask;
+ internal_signal_block_all (&original_sigmask);
+
pid_t pid = arch_fork (&THREAD_SELF->tid);
if (pid == 0)
{
@@ -44,6 +49,8 @@ _Fork (void)
INTERNAL_SYSCALL_CALL (set_robust_list, &self->robust_head,
sizeof (struct robust_list_head));
}
+
+ internal_signal_restore_set (&original_sigmask);
return pid;
}
libc_hidden_def (_Fork)