]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix missing unlock in decoder_pkey.c
authorNeil Horman <nhorman@openssl.org>
Sun, 10 Aug 2025 21:55:15 +0000 (17:55 -0400)
committerNeil Horman <nhorman@openssl.org>
Tue, 12 Aug 2025 18:15:50 +0000 (14:15 -0400)
We hit an assertion failure during a call to CRYPTO_THREAD_read_lock
during memfail testing.

This was caused by us attempting to take a read lock in the same thread
that already held the same lock for writing resulting in an EBUSY
return.

This occured because we triggered a memory failure path in
DECODER_new_for_pkey, which never unlocked a write lock we were holding.

Fix it by ensuring the lock is released in the error path.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28216)

crypto/encode_decode/decoder_pkey.c

index 9fc4e231233121fa21e2326d6877cc4199d23294..5f08536bff12bf02e44effc039675c31dbde5cda 100644 (file)
@@ -928,6 +928,7 @@ OSSL_DECODER_CTX_new_for_pkey(EVP_PKEY **pkey,
             (void)lh_DECODER_CACHE_ENTRY_insert(cache->hashtable, newcache);
             if (lh_DECODER_CACHE_ENTRY_error(cache->hashtable)) {
                 ctx = NULL;
+                CRYPTO_THREAD_unlock(cache->lock);
                 ERR_raise(ERR_LIB_OSSL_DECODER, ERR_R_CRYPTO_LIB);
                 goto err;
             }