From 07af94416ff740b4346689ee4c20cb26a33708c7 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 4 Nov 2020 20:55:36 +0100 Subject: [PATCH] This should fix a lock-order-inversion Calling OPENSSL_init_crypto before acquiring the ossl_property_read_lock in ossl_method_store_fetch makes the second call to OPENSSL_init_crypto from ossl_ctx_global_properties unnecessary. Fixes #12869 Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Matthias St. Pierre (Merged from https://github.com/openssl/openssl/pull/13321) --- crypto/property/property.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/property/property.c b/crypto/property/property.c index 9cfca811909..985709b2047 100644 --- a/crypto/property/property.c +++ b/crypto/property/property.c @@ -338,7 +338,8 @@ int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid, int j, best = -1, score, optional; #ifndef FIPS_MODULE - OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL); + if (!OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG, NULL)) + return 0; #endif if (nid <= 0 || method == NULL || store == NULL) @@ -357,7 +358,7 @@ int ossl_method_store_fetch(OSSL_METHOD_STORE *store, int nid, if (prop_query != NULL) p2 = pq = ossl_parse_query(store->ctx, prop_query); - plp = ossl_ctx_global_properties(store->ctx, 1); + plp = ossl_ctx_global_properties(store->ctx, 0); if (plp != NULL && *plp != NULL) { if (pq == NULL) { pq = *plp; -- 2.47.2