From: Hugo Landau Date: Thu, 8 Feb 2024 10:27:56 +0000 (+0000) Subject: THREADING: Make CRYPTO_MUTEX and CRYPTO_CONDVAR typesafe X-Git-Tag: openssl-3.3.0-alpha1~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62cb7c810e882895a71ba2cc479f482df0aa8e32;p=thirdparty%2Fopenssl.git THREADING: Make CRYPTO_MUTEX and CRYPTO_CONDVAR typesafe There was really no need for this to be void and it made bugs very easy to introduce accidentally, especially given that the free functions needed to be passed a pointer to the pointer. Also fix some bugs in the QUIC code detected immediately by this change. . Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/23519) --- diff --git a/include/internal/quic_reactor.h b/include/internal/quic_reactor.h index 10d54ee1564..47d93eee066 100644 --- a/include/internal/quic_reactor.h +++ b/include/internal/quic_reactor.h @@ -12,6 +12,7 @@ # include "internal/time.h" # include "internal/sockets.h" # include "internal/quic_predef.h" +# include "internal/thread_arch.h" # include # ifndef OPENSSL_NO_QUIC @@ -191,7 +192,7 @@ int ossl_quic_reactor_tick(QUIC_REACTOR *rtor, uint32_t flags); int ossl_quic_reactor_block_until_pred(QUIC_REACTOR *rtor, int (*pred)(void *arg), void *pred_arg, uint32_t flags, - CRYPTO_RWLOCK *mutex); + CRYPTO_MUTEX *mutex); # endif diff --git a/include/internal/thread_arch.h b/include/internal/thread_arch.h index 1bfc0ebb3d3..0994433e7dc 100644 --- a/include/internal/thread_arch.h +++ b/include/internal/thread_arch.h @@ -37,8 +37,8 @@ # include -typedef void CRYPTO_MUTEX; -typedef void CRYPTO_CONDVAR; +typedef struct crypto_mutex_st CRYPTO_MUTEX; +typedef struct crypto_condvar_st CRYPTO_CONDVAR; CRYPTO_MUTEX *ossl_crypto_mutex_new(void); void ossl_crypto_mutex_lock(CRYPTO_MUTEX *mutex); diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index de39a5c7aa7..af505d12032 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -453,7 +453,7 @@ SSL *ossl_quic_new(SSL_CTX *ctx) err: if (ssl_base == NULL) { #if defined(OPENSSL_THREADS) - ossl_crypto_mutex_free(qc->mutex); + ossl_crypto_mutex_free(&qc->mutex); #endif OPENSSL_free(qc); } else { diff --git a/ssl/quic/quic_thread_assist.c b/ssl/quic/quic_thread_assist.c index e1de72a910a..ad49781c742 100644 --- a/ssl/quic/quic_thread_assist.c +++ b/ssl/quic/quic_thread_assist.c @@ -91,7 +91,7 @@ int ossl_quic_thread_assist_init_start(QUIC_THREAD_ASSIST *qta, qta->t = ossl_crypto_thread_native_start(assist_thread_main, qta, /*joinable=*/1); if (qta->t == NULL) { - ossl_crypto_condvar_free(qta->cv); + ossl_crypto_condvar_free(&qta->cv); return 0; }