From: cchinchole Date: Tue, 2 Jul 2024 07:56:22 +0000 (-0500) Subject: Fixes for potential deadlock X-Git-Tag: openssl-3.3.2~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eddbe3a152fadfbda07c8dc1c8f44ec2c536d837;p=thirdparty%2Fopenssl.git Fixes for potential deadlock Fixes (#24517): (3/3) Addresses the potential deadlock if an error occurs from up_ref in functions ENGINE_get_first, ENGINE_get_last, ENGINE_get_next, and ENGINE_get_prev in file crypto/engine/eng_list.c CLA: trivial Reviewed-by: Neil Horman Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/24780) (cherry picked from commit e6174ca4d48f6f4f954dd87f2cdf3718af14f064) --- diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index a2c151d64a0..eafca3ec49c 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -243,6 +243,7 @@ ENGINE *ENGINE_get_first(void) int ref; if (!CRYPTO_UP_REF(&ret->struct_ref, &ref)) { + CRYPTO_THREAD_unlock(global_engine_lock); ERR_raise(ERR_LIB_ENGINE, ERR_R_CRYPTO_LIB); return NULL; } @@ -269,6 +270,7 @@ ENGINE *ENGINE_get_last(void) int ref; if (!CRYPTO_UP_REF(&ret->struct_ref, &ref)) { + CRYPTO_THREAD_unlock(global_engine_lock); ERR_raise(ERR_LIB_ENGINE, ERR_R_CRYPTO_LIB); return NULL; } @@ -294,6 +296,7 @@ ENGINE *ENGINE_get_next(ENGINE *e) /* Return a valid structural reference to the next ENGINE */ if (!CRYPTO_UP_REF(&ret->struct_ref, &ref)) { + CRYPTO_THREAD_unlock(global_engine_lock); ERR_raise(ERR_LIB_ENGINE, ERR_R_CRYPTO_LIB); return NULL; } @@ -320,6 +323,7 @@ ENGINE *ENGINE_get_prev(ENGINE *e) /* Return a valid structural reference to the next ENGINE */ if (!CRYPTO_UP_REF(&ret->struct_ref, &ref)) { + CRYPTO_THREAD_unlock(global_engine_lock); ERR_raise(ERR_LIB_ENGINE, ERR_R_CRYPTO_LIB); return NULL; }