From: Matt Van Horn Date: Fri, 1 May 2026 04:46:43 +0000 (-0700) Subject: providers/defltprov.c: remove static globals from provider_init X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57f4bd9ab801c9d362ef5e110b74362f41db26c3;p=thirdparty%2Fopenssl.git providers/defltprov.c: remove static globals from provider_init The default provider stored two function pointers from the core dispatch table (c_gettable_params, c_get_params) in file-scope statics, written by ossl_default_provider_init() without any synchronization. When OSSL_PROVIDER_load() is invoked from multiple threads concurrently, TSAN reports a data race on both writes[1]. c_gettable_params is never read anywhere in the file; it was dead storage. c_get_params is only consumed once, inside the same call to ossl_default_provider_init(), to seed the provider context via ossl_prov_ctx_set0_core_get_params(). It can therefore be a local variable rather than file-scope state. Drop the unused c_gettable_params static together with its dispatch case, and scope c_get_params inside the init function. The behavior of the default provider is unchanged for single-threaded callers; the concurrent-load race goes away because the shared mutable state is gone. [1] https://github.com/openssl/openssl/issues/28935 CLA: trivial Resolves: https://github.com/openssl/openssl/issues/28935 Reviewed-by: Norbert Pocs Reviewed-by: Neil Horman Reviewed-by: Eugene Syromiatnikov MergeDate: Sun Jun 28 17:51:52 2026 (Merged from https://github.com/openssl/openssl/pull/31508) --- diff --git a/providers/defltprov.c b/providers/defltprov.c index c471cf8e7e6..1f39b34d6e1 100644 --- a/providers/defltprov.c +++ b/providers/defltprov.c @@ -34,10 +34,6 @@ static OSSL_FUNC_provider_query_operation_fn deflt_query; #define ALGC(NAMES, FUNC, CHECK) { { NAMES, "provider=default", FUNC }, CHECK } #define ALG(NAMES, FUNC) ALGC(NAMES, FUNC, NULL) -/* Functions provided by the core */ -static OSSL_FUNC_core_gettable_params_fn *c_gettable_params = NULL; -static OSSL_FUNC_core_get_params_fn *c_get_params = NULL; - /* Parameters we provide to the core */ static const OSSL_PARAM deflt_param_types[] = { OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0), @@ -799,6 +795,7 @@ int ossl_default_provider_init(const OSSL_CORE_HANDLE *handle, void **provctx) { OSSL_FUNC_core_get_libctx_fn *c_get_libctx = NULL; + OSSL_FUNC_core_get_params_fn *c_get_params = NULL; BIO_METHOD *corebiometh; if (!ossl_prov_bio_from_dispatch(in) @@ -806,9 +803,6 @@ int ossl_default_provider_init(const OSSL_CORE_HANDLE *handle, return 0; for (; in->function_id != 0; in++) { switch (in->function_id) { - case OSSL_FUNC_CORE_GETTABLE_PARAMS: - c_gettable_params = OSSL_FUNC_core_gettable_params(in); - break; case OSSL_FUNC_CORE_GET_PARAMS: c_get_params = OSSL_FUNC_core_get_params(in); break;