From d41e042c398e34e60fa37d1e083ced1cfae24c2f Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 31 Mar 2022 02:02:03 +0000 Subject: [PATCH 20/49] rtld: Convert membar_exit/enter to membar_release/acquire. These are basic CAS-based locking primitives needing release and acquire semantics, nothing fancy here -- except the membar_sync parts which are questionable but not relevant to the present audit. --- libexec/ld.elf_so/rtld.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libexec/ld.elf_so/rtld.c b/libexec/ld.elf_so/rtld.c index 59ed3c4530b2..f08664529bb8 100644 --- a/libexec/ld.elf_so/rtld.c +++ b/libexec/ld.elf_so/rtld.c @@ -1682,7 +1682,7 @@ _rtld_shared_enter(void) /* Yes, so increment use counter */ if (atomic_cas_uint(&_rtld_mutex, cur, cur + 1) != cur) continue; - membar_enter(); + membar_acquire(); return; } /* @@ -1728,7 +1728,7 @@ _rtld_shared_exit(void) * Wakeup LWPs waiting for an exclusive lock if this is the last * LWP on the shared lock. */ - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&_rtld_mutex)) return; membar_sync(); @@ -1750,7 +1750,7 @@ _rtld_exclusive_enter(sigset_t *mask) for (;;) { if (atomic_cas_uint(&_rtld_mutex, 0, locked_value) == 0) { - membar_enter(); + membar_acquire(); break; } waiter = atomic_swap_uint(&_rtld_waiter_exclusive, self); @@ -1774,7 +1774,7 @@ _rtld_exclusive_exit(sigset_t *mask) { lwpid_t waiter; - membar_exit(); + membar_release(); _rtld_mutex = 0; membar_sync(); if ((waiter = _rtld_waiter_exclusive) != 0)