From: Bernd Edlinger Date: Mon, 15 Sep 2025 19:12:37 +0000 (+0200) Subject: Fix another memory order issue X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d296f9653345d79ee316c053f63a489f001565a5;p=thirdparty%2Fopenssl.git Fix another memory order issue this adds another release/acquire link between update_qp and get_hold_current_qp via the reader_idx because the current one which is based on the qp users count is only preventing a race condition, but does not help when the reader acquires the next qp. Fixes #27267 Reviewed-by: Neil Horman Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/28585) --- diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 5d5d64baf2a..4dcdccf7bcb 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -309,7 +309,7 @@ static struct rcu_qp *get_hold_current_qp(struct rcu_lock_st *lock) /* if the idx hasn't changed, we're good, else try again */ if (qp_idx == ATOMIC_LOAD_N(uint32_t, &lock->reader_idx, - __ATOMIC_RELAXED)) + __ATOMIC_ACQUIRE)) break; ATOMIC_SUB_FETCH(&lock->qp_group[qp_idx].users, (uint64_t)1, @@ -440,8 +440,12 @@ static struct rcu_qp *update_qp(CRYPTO_RCU_LOCK *lock, uint32_t *curr_id) *curr_id = lock->id_ctr; lock->id_ctr++; + /* + * make the current state of everything visible by this release + * when get_hold_current_qp acquires the next qp + */ ATOMIC_STORE_N(uint32_t, &lock->reader_idx, lock->current_alloc_idx, - __ATOMIC_RELAXED); + __ATOMIC_RELEASE); /* * this should make sure that the new value of reader_idx is visible in