]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Remove CRYPTO_GET_REF
authorNeil Horman <nhorman@openssl.org>
Fri, 26 Jun 2026 17:18:49 +0000 (13:18 -0400)
committerNeil Horman <nhorman@openssl.org>
Sat, 4 Jul 2026 16:47:07 +0000 (12:47 -0400)
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 <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Sat Jul  4 16:47:16 2026
(Merged from https://github.com/openssl/openssl/pull/31750)

include/internal/refcount.h

index 11f207f881b13772f116c0494851d70fa375f0a9..2e7dedf2c3a162383bd2238c3e1a6536673691e0 100644 (file)
@@ -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