From 84b0a3a63c9fa29857be4c8c87fc1050d16338fc Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 17 Feb 2025 05:53:09 +0100 Subject: [PATCH] Access cb_items under write_lock in ossl_synchronize_rcu Fixes: 74a52ca9b793 "Don't use __ATOMIC_ACQ_REL on older compilers" Reviewed-by: Neil Horman Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/26790) --- crypto/threads_pthread.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 2e2e6121214..06f1ea8855e 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -514,12 +514,10 @@ void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock) uint32_t curr_id; struct rcu_cb_item *cb_items, *tmpcb; - /* - * __ATOMIC_ACQ_REL is used here to ensure that we get any prior published - * writes before we read, and publish our write immediately - */ - cb_items = ATOMIC_EXCHANGE_N(prcu_cb_item, &lock->cb_items, NULL, - __ATOMIC_ACQ_REL); + pthread_mutex_lock(&lock->write_lock); + cb_items = lock->cb_items; + lock->cb_items = NULL; + pthread_mutex_unlock(&lock->write_lock); qp = update_qp(lock, &curr_id); -- 2.47.2