]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix list appending in win ossl_rcu_call
authorNeil Horman <nhorman@openssl.org>
Thu, 29 Feb 2024 14:49:37 +0000 (09:49 -0500)
committerPauli <ppzgs1@gmail.com>
Wed, 24 Apr 2024 02:03:03 +0000 (12:03 +1000)
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 <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23671)

crypto/threads_pthread.c
crypto/threads_win.c

index 33e225b9957e33b5064760870d94458db2575bd7..69b68e5226d7a15e64b0c3f3157c0a13a7583d5c 100644 (file)
@@ -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;
index 873b2bd78c9620ead1ee7eb824bde5ef6bca8faa..6bcbaea10fca762cdd69eae9e208812fa1aa4c06 100644 (file)
@@ -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;
 }