From 7e45ac6891ade57cb0141402745d144c4ce342cb Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Fri, 8 Mar 2024 11:58:07 -0500 Subject: Add CRYPTO_atomic_store api Generally we can get away with just using CRYPTO_atomic_load to do stores by reversing the source and target variables, but doing so creates a problem for the thread sanitizer as CRYPTO_atomic_load hard codes an __ATOMIC_ACQUIRE constraint, which confuses tsan into thinking that loads and stores aren't properly ordered, leading to RAW/WAR hazzards getting reported. Instead create a CRYPTO_atomic_store api that is identical to the load variant, save for the fact that the value is a unit64_t rather than a pointer that gets stored using an __ATOMIC_RELEASE constraint, satisfying tsan. Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/23671) --- include/openssl/crypto.h.in | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/openssl/crypto.h.in b/include/openssl/crypto.h.in index b2d691b90f..220a2df354 100644 --- a/include/openssl/crypto.h.in +++ b/include/openssl/crypto.h.in @@ -90,6 +90,7 @@ int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret, CRYPTO_RWLOCK *lock); int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock); int CRYPTO_atomic_load_int(int *val, int *ret, CRYPTO_RWLOCK *lock); +int CRYPTO_atomic_store(uint64_t *dst, uint64_t val, CRYPTO_RWLOCK *lock); /* No longer needed, so this is a no-op */ #define OPENSSL_malloc_init() while(0) continue -- cgit v1.2.3