>From 7e661e4ff9f70b625e496b54729943bf3f7ecfac Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 28 Sep 2020 19:32:34 -0400 Subject: [PATCH 5/5] fix race deadlock with abort in forked child of multithreaded parent if the multithreaded parent forked while another thread was calling sigaction for SIGABRT or calling abort, the child could inherit a lock state in which future calls to abort will deadlock. this is nonconforming since abort is AS-safe and permitted to be called in the MT-forked child. since there is no userspace data state protected by the lock (it's only used to exclude sigaction for SIGABRT while abort is in progress), just reset the lock word to 0 in the child rather than holding the lock across the fork. --- src/process/fork.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/process/fork.c b/src/process/fork.c index 538a0bcb..b5a5fa11 100644 --- a/src/process/fork.c +++ b/src/process/fork.c @@ -33,6 +33,7 @@ pid_t fork(void) __thread_list_lock = 0; libc.threads_minus_1 = 0; if (libc.need_locks > 0) libc.need_locks = -2; + *__abort_lock = 0; } __aio_atfork(!ret); __restore_sigs(&set); -- 2.21.0