-/* $OpenBSD: rthread.c,v 1.83 2015/05/19 20:50:06 guenther Exp $ */
+/* $OpenBSD: rthread.c,v 1.84 2015/10/18 08:02:58 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
#ifndef NO_PIC
if (_DYNAMIC) {
- /*
- * To avoid recursion problems in ld.so, we need to trigger the
- * functions once to fully bind them before registering them
- * for use.
- */
- _rthread_dl_lock(0);
- _rthread_dl_lock(1);
- _rthread_bind_lock(0);
- _rthread_bind_lock(1);
- sched_yield();
dlctl(NULL, DL_SETTHREADLCK, _rthread_dl_lock);
- dlctl(NULL, DL_SETBINDLCK, _rthread_bind_lock);
}
#endif
TAILQ_INIT(&lockers);
}
}
-
-void
-_rthread_bind_lock(int what)
-{
- static struct _spinlock lock = _SPINLOCK_UNLOCKED;
-
- if (what == 0)
- _spinlock(&lock);
- else
- _spinunlock(&lock);
-}
#endif
-/* $OpenBSD: rthread.h,v 1.52 2015/05/19 20:50:06 guenther Exp $ */
+/* $OpenBSD: rthread.h,v 1.53 2015/10/18 08:02:58 guenther Exp $ */
/*
* Copyright (c) 2004,2005 Ted Unangst <tedu@openbsd.org>
* All Rights Reserved.
void _rthread_debug_init(void);
#ifndef NO_PIC
void _rthread_dl_lock(int what);
-void _rthread_bind_lock(int);
#endif
/* rthread_cancel.c */
-/* $OpenBSD: rthread_fork.c,v 1.13 2015/05/19 20:50:06 guenther Exp $ */
+/* $OpenBSD: rthread_fork.c,v 1.14 2015/10/18 08:02:58 guenther Exp $ */
/*
* Copyright (c) 2008 Kurt Miller <kurt@openbsd.org>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
-#include <signal.h>
#include "thread_private.h" /* in libc/include */
pthread_t me;
pid_t (*sys_fork)(void);
pid_t newid;
-#ifndef NO_PIC
- sigset_t nmask, omask;
-#endif
sys_fork = is_vfork ? &_thread_sys_vfork : &_thread_sys_fork;
/*
* Protect important libc/ld.so critical areas across the fork call.
* dlclose() will grab the atexit lock via __cxa_finalize() so lock
- * the dl_lock first. malloc()/free() can grab the arc4 lock so lock
- * malloc_lock first. Finally lock the bind_lock last so that any lazy
- * binding in the other locking functions can succeed.
+ * the dl_lock first. malloc()/free() can use arc4random(), so lock
+ * malloc_lock before arc4_lock
*/
#ifndef NO_PIC
_thread_malloc_lock();
_thread_arc4_lock();
-#ifndef NO_PIC
- if (_DYNAMIC) {
- sigfillset(&nmask);
- _thread_sys_sigprocmask(SIG_BLOCK, &nmask, &omask);
- _rthread_bind_lock(0);
- }
-#endif
-
newid = sys_fork();
-#ifndef NO_PIC
- if (_DYNAMIC) {
- _rthread_bind_lock(1);
- _thread_sys_sigprocmask(SIG_SETMASK, &omask, NULL);
- }
-#endif
-
_thread_arc4_unlock();
_thread_malloc_unlock();
_thread_atexit_unlock();