Skip to content

Commit

Permalink
Fixes for potential deadlock
Browse files Browse the repository at this point in the history
Fixes (openssl#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 <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#24780)
  • Loading branch information
cchinchole authored and t8m committed Jul 3, 2024
1 parent b5863e9 commit e6174ca
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crypto/engine/eng_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit e6174ca

Please sign in to comment.