[openssl/openssl] 2fd6c1: crypto/provider_core.c: Allocate activatecnt_lock
Oleg Bulatov
noreply at github.com
Thu Apr 11 08:09:58 UTC 2024
Branch: refs/heads/master
Home: https://github.com/openssl/openssl
Commit: 2fd6c12e85ec7558cbdee08033f822c42ee0f5d4
https://github.com/openssl/openssl/commit/2fd6c12e85ec7558cbdee08033f822c42ee0f5d4
Author: Oleg Bulatov <oleg at bulatov.me>
Date: 2024-04-11 (Thu, 11 Apr 2024)
Changed paths:
M crypto/provider_core.c
Log Message:
-----------
crypto/provider_core.c: Allocate activatecnt_lock
CRYPTO_atomic_add has a lock as a parameter, which is often ignored, but in
some cases (for example, when BROKEN_CLANG_ATOMICS is defined) it is required.
There is no easy way to determine if the lock is needed or not. The current
logic looks like this:
if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && !defined(OPENSSL_SYS_WINDOWS)
if defined(__GNUC__) && defined(__ATOMIC_ACQ_REL) && !defined(BROKEN_CLANG_ATOMICS)
- It works without the lock, but in general the need for the
lock depends on __atomic_is_lock_free results
elif defined(__sun) && (defined(__SunOS_5_10) || defined(__SunOS_5_11))
- The lock is not needed (unless ret is NULL, which should never
happen?)
else
- The lock is required
endif
else
- The lock is not needed
endif
Adding such conditions outside of crypto.h is error-prone, so it is better to
always allocate the lock, otherwise CRYPTO_atomic_add may silently fail.
Fixes #23376.
CLA: trivial
Fixes: fc570b2605 ("Avoid taking a write lock in ossl_provider_doall_activated()")
Signed-off-by: Oleg Bulatov <oleg at bulatov.me>
Reviewed-by: Tim Hudson <tjh at openssl.org>
Reviewed-by: Tomas Mraz <tomas at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24081)
To unsubscribe from these emails, change your notification settings at https://github.com/openssl/openssl/settings/notifications
More information about the openssl-commits
mailing list