summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2013-06-21 06:50:49 +0000
committerguenther <guenther@openbsd.org>2013-06-21 06:50:49 +0000
commita3f8367822da862042e8d6a24e92d9e8b5cb5c83 (patch)
tree6d81445f627a7632e843da5e4c39a95b3dd821b8
parentDefault to stdin/stdout if no input files are (diff)
downloadwireguard-openbsd-a3f8367822da862042e8d6a24e92d9e8b5cb5c83.tar.xz
wireguard-openbsd-a3f8367822da862042e8d6a24e92d9e8b5cb5c83.zip
The bind lock must only be grabbed with all signals masked.
backtrace of example case from sthen@ ok kettenis@ millert@
-rw-r--r--lib/librthread/rthread_fork.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/librthread/rthread_fork.c b/lib/librthread/rthread_fork.c
index b46698b75c9..8b1aedcc72a 100644
--- a/lib/librthread/rthread_fork.c
+++ b/lib/librthread/rthread_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rthread_fork.c,v 1.7 2013/06/01 20:47:40 tedu Exp $ */
+/* $OpenBSD: rthread_fork.c,v 1.8 2013/06/21 06:50:49 guenther Exp $ */
/*
* Copyright (c) 2008 Kurt Miller <kurt@openbsd.org>
@@ -40,6 +40,7 @@
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
+#include <signal.h>
#include "thread_private.h" /* in libc/include */
@@ -67,6 +68,7 @@ _dofork(int is_vfork)
pthread_t me;
pid_t (*sys_fork)(void);
pid_t newid;
+ sigset_t nmask, omask;
sys_fork = is_vfork ? &_thread_sys_vfork : &_thread_sys_fork;
@@ -93,15 +95,20 @@ _dofork(int is_vfork)
_thread_arc4_lock();
#if defined(__ELF__)
- if (_DYNAMIC)
+ if (_DYNAMIC) {
+ sigfillset(&nmask);
+ _thread_sys_sigprocmask(SIG_BLOCK, &nmask, &omask);
_rthread_bind_lock(0);
+ }
#endif
newid = sys_fork();
#if defined(__ELF__)
- if (_DYNAMIC)
+ if (_DYNAMIC) {
_rthread_bind_lock(1);
+ _thread_sys_sigprocmask(SIG_SETMASK, &omask, NULL);
+ }
#endif
_thread_arc4_unlock();