mirror of
https://github.com/openssl/openssl.git
synced 2025-04-06 20:20:50 +08:00
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)
This commit is contained in:
parent
cd4e6a3512
commit
b233ea8276
@ -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;
|
||||
}
|
||||
|
@ -434,8 +434,6 @@ static const OSSL_ALGORITHM *fips_query(void *provctx, int operation_id,
|
||||
case OSSL_OP_DIGEST:
|
||||
return fips_digests;
|
||||
case OSSL_OP_CIPHER:
|
||||
ossl_prov_cache_exported_algorithms(fips_ciphers,
|
||||
exported_fips_ciphers);
|
||||
return exported_fips_ciphers;
|
||||
case OSSL_OP_MAC:
|
||||
return fips_macs;
|
||||
@ -626,6 +624,8 @@ int OSSL_provider_init(const OSSL_CORE_HANDLE *handle,
|
||||
|
||||
fgbl->handle = handle;
|
||||
|
||||
ossl_prov_cache_exported_algorithms(fips_ciphers, exported_fips_ciphers);
|
||||
|
||||
selftest_params.libctx = libctx;
|
||||
if (!SELF_TEST_post(&selftest_params, 0)) {
|
||||
ERR_raise(ERR_LIB_PROV, PROV_R_SELF_TEST_POST_FAILURE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user