From: Neil Horman Date: Thu, 29 Feb 2024 14:49:37 +0000 (-0500) Subject: Fix list appending in win ossl_rcu_call X-Git-Tag: openssl-3.4.0-alpha1~655 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f39a86281883bd7ff0b3791ed203756d055c001b;p=thirdparty%2Fopenssl.git Fix list appending in win ossl_rcu_call The ossl_rcu_call function for windows creates a linked list loop. fix it to work like the pthread version properly Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/23671) --- diff --git a/crypto/threads_pthread.c b/crypto/threads_pthread.c index 33e225b9957..69b68e5226d 100644 --- a/crypto/threads_pthread.c +++ b/crypto/threads_pthread.c @@ -581,10 +581,6 @@ void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock) uint64_t count; 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 - */ pthread_mutex_lock(&lock->write_lock); cb_items = lock->cb_items; lock->cb_items = NULL; diff --git a/crypto/threads_win.c b/crypto/threads_win.c index 873b2bd78c9..6bcbaea10fc 100644 --- a/crypto/threads_win.c +++ b/crypto/threads_win.c @@ -357,17 +357,14 @@ void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock) int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data) { struct rcu_cb_item *new; - struct rcu_cb_item *prev; new = OPENSSL_zalloc(sizeof(struct rcu_cb_item)); if (new == NULL) return 0; - prev = new; new->data = data; new->fn = cb; - InterlockedExchangePointer((void * volatile *)&lock->cb_items, prev); - new->next = prev; + new->next = InterlockedExchangePointer((void * volatile *)&lock->cb_items, new); return 1; }