]> sourceware.org Git - glibc.git/commitdiff
Linux: Block signals around _Fork (bug 32215)
authorFlorian Weimer <fweimer@redhat.com>
Sat, 28 Sep 2024 07:44:25 +0000 (09:44 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Sat, 28 Sep 2024 07:44:25 +0000 (09:44 +0200)
This hides the inconsistent TCB state (missing robust mutex list) from
signal handlers.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
sysdeps/nptl/_Fork.c

index ef199ddbc37e556cee533fc6b4bd8a6f1a88a39b..fd2cfc7840d12ac5fbf3f55d8fd1f42a2c92b14e 100644 (file)
 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)
This page took 0.041775 seconds and 5 git commands to generate.