aboutsummaryrefslogtreecommitdiff
path: root/libexec/rtld-elf
diff options
context:
space:
mode:
authorDavid Xu <davidxu@FreeBSD.org>2008-09-16 01:46:11 +0000
committerDavid Xu <davidxu@FreeBSD.org>2008-09-16 01:46:11 +0000
commitd8b04dc0d4f3031359b13b393b639c69f134b265 (patch)
tree5ab66ac98cafb8b41c940604c8e79e1bd9507c84 /libexec/rtld-elf
parentc139f23d171c1a032ae57608f8dd72c47cda701e (diff)
downloadsrc-d8b04dc0d4f3031359b13b393b639c69f134b265.tar.gz
src-d8b04dc0d4f3031359b13b393b639c69f134b265.zip
Allow multiple locks to be acquired by detecting corresponding
bit flag, otherwise if a thread acquired a lock, another thread or the current thread itself can no longer acquire another lock because thread_mask_set() return whole flag word, this results bit leaking in the word and misbehavior in later locking and unlocking.
Notes
Notes: svn path=/head/; revision=183061
Diffstat (limited to 'libexec/rtld-elf')
-rw-r--r--libexec/rtld-elf/rtld_lock.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c
index c67f5fb0d545..5bb891a2ae82 100644
--- a/libexec/rtld-elf/rtld_lock.c
+++ b/libexec/rtld-elf/rtld_lock.c
@@ -184,7 +184,7 @@ rtld_lock_t rtld_phdr_lock = &rtld_locks[2];
int
rlock_acquire(rtld_lock_t lock)
{
- if (thread_mask_set(lock->mask)) {
+ if (thread_mask_set(lock->mask) & lock->mask) {
dbg("rlock_acquire: recursed");
return (0);
}
@@ -195,7 +195,7 @@ rlock_acquire(rtld_lock_t lock)
int
wlock_acquire(rtld_lock_t lock)
{
- if (thread_mask_set(lock->mask)) {
+ if (thread_mask_set(lock->mask) & lock->mask) {
dbg("wlock_acquire: recursed");
return (0);
}