summaryrefslogtreecommitdiffstats
path: root/providers/defltprov.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-01-26 15:23:19 +0000
committerMatt Caswell <matt@openssl.org>2021-02-02 12:21:21 +0000
commitb233ea82765e80038e4884564153f9c8543d9396 (patch)
tree85bc23683d1165916623957b68f3da16c83b8cba /providers/defltprov.c
parentcd4e6a351201270cd2769e1e2af7e9fb875a3f80 (diff)
Avoid races by caching exported ciphers in the init function
TSAN was reporting a race of the exported ciphers cache that we create in the default and fips providers. This was because we cached it in the query function rather than the init function, so this would cause a race if multiple threads queried at the same time. In practice it probably wouldn't make much difference since different threads should come up with the same answer. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13987)
Diffstat (limited to 'providers/defltprov.c')
-rw-r--r--providers/defltprov.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/providers/defltprov.c b/providers/defltprov.c
index 2a1ebb6218..c246ed42be 100644
--- a/providers/defltprov.c
+++ b/providers/defltprov.c
@@ -472,7 +472,6 @@ static const OSSL_ALGORITHM *deflt_query(void *provctx, int operation_id,
case OSSL_OP_DIGEST:
return deflt_digests;
case OSSL_OP_CIPHER:
- ossl_prov_cache_exported_algorithms(deflt_ciphers, exported_ciphers);
return exported_ciphers;
case OSSL_OP_MAC:
return deflt_macs;
@@ -570,6 +569,7 @@ int ossl_default_provider_init(const OSSL_CORE_HANDLE *handle,
ossl_prov_ctx_set0_core_bio_method(*provctx, corebiometh);
*out = deflt_dispatch_table;
+ ossl_prov_cache_exported_algorithms(deflt_ciphers, exported_ciphers);
return 1;
}