diff options
author | kib <kib@FreeBSD.org> | 2011-01-09 12:38:40 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2011-01-09 12:38:40 +0000 |
commit | b2e3ee7d07d38a011d50e0ce65fe146aafb5c939 (patch) | |
tree | 3e9a8bc61608f36b6d941a6fe4ca52880cc1c222 /lib/libthr/thread/thr_rtld.c | |
parent | 13fb4c75946c522dc61a068915f8ebe021d256c7 (diff) | |
download | FreeBSD-src-b2e3ee7d07d38a011d50e0ce65fe146aafb5c939.zip FreeBSD-src-b2e3ee7d07d38a011d50e0ce65fe146aafb5c939.tar.gz |
Implement the __pthread_map_stacks_exec() for libthr.
Stack creation code is changed to call _rtld_get_stack_prot() to get
the stack protection right. There is a race where thread is created
during dlopen() of dso that requires executable stacks. Then,
_rtld_get_stack_prot() may return PROT_READ | PROT_WRITE, but thread
is still not linked into the thread list. In this case, the callback
misses the thread stack, and rechecks the required protection
afterward.
Reviewed by: davidxu
Diffstat (limited to 'lib/libthr/thread/thr_rtld.c')
-rw-r--r-- | lib/libthr/thread/thr_rtld.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c index e6af702..d9dd94d 100644 --- a/lib/libthr/thread/thr_rtld.c +++ b/lib/libthr/thread/thr_rtld.c @@ -31,6 +31,8 @@ * A lockless rwlock for rtld. */ #include <sys/cdefs.h> +#include <sys/mman.h> +#include <link.h> #include <stdlib.h> #include <string.h> @@ -194,6 +196,9 @@ _thr_rtld_init(void) /* force to resolve memcpy PLT */ memcpy(&dummy, &dummy, sizeof(dummy)); + mprotect(NULL, 0, 0); + _rtld_get_stack_prot(); + li.lock_create = _thr_rtld_lock_create; li.lock_destroy = _thr_rtld_lock_destroy; li.rlock_acquire = _thr_rtld_rlock_acquire; |