From: Neil Horman Date: Fri, 26 Jun 2026 17:18:49 +0000 (-0400) Subject: Remove CRYPTO_GET_REF X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=562d2a137a53faac1f2d59e23e3eb458af2edac7;p=thirdparty%2Fopenssl.git Remove CRYPTO_GET_REF This function should never have existed. Its a TOCTOU waiting to happen. Now that we've eliminated all internal uses, and given that its an internal function, send it to a nice farm upstate, where it can run and play with all the other functions that shouldn't have been. Reviewed-by: Kurt Roeckx Reviewed-by: Paul Dale Reviewed-by: Norbert Pocs Reviewed-by: Nikola Pajkovsky Reviewed-by: Bob Beck MergeDate: Sat Jul 4 16:47:16 2026 (Merged from https://github.com/openssl/openssl/pull/31750) --- diff --git a/include/internal/refcount.h b/include/internal/refcount.h index 11f207f881b..2e7dedf2c3a 100644 --- a/include/internal/refcount.h +++ b/include/internal/refcount.h @@ -68,12 +68,6 @@ static inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -static inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) -{ - *ret = atomic_load_explicit(&refcnt->val, memory_order_acquire); - return 1; -} - #elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0 #define HAVE_ATOMICS 1 @@ -96,12 +90,6 @@ static __inline__ int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -static __inline__ int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) -{ - *ret = __atomic_load_n(&refcnt->val, __ATOMIC_RELAXED); - return 1; -} - #elif defined(__ICL) && defined(_WIN32) #define HAVE_ATOMICS 1 @@ -121,12 +109,6 @@ static __inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -static __inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) -{ - *ret = _InterlockedExchangeAdd((void *)&refcnt->val, 0); - return 1; -} - #elif defined(_MSC_VER) && _MSC_VER >= 1200 #define HAVE_ATOMICS 1 @@ -153,12 +135,6 @@ static __inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -static __inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) -{ - *ret = _InterlockedExchangeAdd_acq((void *)&refcnt->val, 0); - return 1; -} - #else #pragma intrinsic(_InterlockedExchangeAdd) @@ -174,12 +150,6 @@ static __inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, int *ret) return 1; } -static __inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, int *ret) -{ - *ret = _InterlockedExchangeAdd(&refcnt->val, 0); - return 1; -} - #endif #endif @@ -213,12 +183,6 @@ static ossl_unused ossl_inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, return CRYPTO_atomic_add(&refcnt->val, -1, ret, refcnt->lock); } -static ossl_unused ossl_inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) -{ - return CRYPTO_atomic_load_int(&refcnt->val, ret, refcnt->lock); -} - #define CRYPTO_NEW_FREE_DEFINED 1 static ossl_unused ossl_inline int CRYPTO_NEW_REF(CRYPTO_REF_COUNT *refcnt, int n) { @@ -255,13 +219,6 @@ static ossl_unused ossl_inline int CRYPTO_DOWN_REF(CRYPTO_REF_COUNT *refcnt, return 1; } -static ossl_unused ossl_inline int CRYPTO_GET_REF(CRYPTO_REF_COUNT *refcnt, - int *ret) -{ - *ret = refcnt->val; - return 1; -} - #endif /* OPENSSL_THREADS */ #endif