From 24d16d3a1915a06a2130385a87de9a37fc09c4b9 Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Mon, 15 Apr 2024 16:56:29 -0400 Subject: Make rcu_thread_key context-aware Currently, rcu has a global bit of data, the CRYPTO_THREAD_LOCAL object to store per thread data. This works in some cases, but fails in FIPS, becuase it contains its own copy of the global key. So 1) Make the rcu_thr_key a per-context variable, and force ossl_rcu_lock_new to be context aware 2) Store a pointer to the context in the lock object 3) Use the context to get the global thread key on read/write lock 4) Use ossl_thread_start_init to properly register a cleanup on thread exit 5) Fix up missed calls to OSSL_thread_stop() in our tests Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/24162) --- doc/internal/man3/ossl_rcu_lock_new.pod | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/internal/man3/ossl_rcu_lock_new.pod b/doc/internal/man3/ossl_rcu_lock_new.pod index 7b82f6bbd0..57b5e4d73d 100644 --- a/doc/internal/man3/ossl_rcu_lock_new.pod +++ b/doc/internal/man3/ossl_rcu_lock_new.pod @@ -13,7 +13,7 @@ ossl_rcu_assign_uptr =head1 SYNOPSIS - CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers); + CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx); void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock); void ossl_rcu_write_lock(CRYPTO_RCU_LOCK *lock); void ossl_rcu_write_unlock(CRYPTO_RCU_LOCK *lock); @@ -65,7 +65,8 @@ ossl_rcu_lock_new() allocates a new RCU lock. The I param indicates the number of write side threads which may execute ossl_synchronize_rcu() in parallel. The value must be at least 1, but may be larger to obtain increased write side throughput at the cost of additional -internal memory usage. A value of 1 is generally recommended. +internal memory usage. A value of 1 is generally recommended. The I +parameter references the library context in which the lock is allocated. =item * -- cgit v1.2.3