From d84f5515faf3fe00ed5eeca7e7b8b041be863e90 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 19 Feb 2021 17:03:43 +0000 Subject: Don't hold a lock when calling a callback in ossl_namemap_doall_names We don't want to hold a read lock when calling a user supplied callback. That callback could do anything so the risk of a deadlock is high. Instead we collect all the names first inside the read lock, and then subsequently call the user callback outside the read lock. Fixes #14225 Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/14250) --- crypto/evp/digest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crypto/evp/digest.c') diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index 7346169be6..e322654241 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -881,8 +881,8 @@ static void *evp_md_from_dispatch(int name_id, #ifndef FIPS_MODULE /* TODO(3.x) get rid of the need for legacy NIDs */ md->type = NID_undef; - evp_names_do_all(prov, name_id, set_legacy_nid, &md->type); - if (md->type == -1) { + if (!evp_names_do_all(prov, name_id, set_legacy_nid, &md->type) + || md->type == -1) { ERR_raise(ERR_LIB_EVP, ERR_R_INTERNAL_ERROR); EVP_MD_free(md); return NULL; -- cgit v1.2.3