From: Richard Levitte Date: Mon, 11 May 2020 09:10:41 +0000 (+0200) Subject: CORE: Attach the provider context to the provider late X-Git-Tag: openssl-3.0.0-alpha2~46 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=914db66d2337d560b042ac710817c69b89045d52;p=oweals%2Fopenssl.git CORE: Attach the provider context to the provider late There are concerns that if |prov->provctx| is populated early, sensitive information may leak from the provider. Therefore, we use a temporary variable, and only assign it to |prov->provctx| when the provider init function has returned successfully. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/11777) --- diff --git a/crypto/provider_core.c b/crypto/provider_core.c index b100e5a15d..1cbe369754 100644 --- a/crypto/provider_core.c +++ b/crypto/provider_core.c @@ -418,6 +418,7 @@ int OSSL_PROVIDER_set_default_search_path(OPENSSL_CTX *libctx, const char *path) static int provider_activate(OSSL_PROVIDER *prov) { const OSSL_DISPATCH *provider_dispatch = NULL; + void *tmp_provctx = NULL; /* safety measure */ #ifndef OPENSSL_NO_ERR # ifndef FIPS_MODULE OSSL_provider_get_reason_strings_fn *p_get_reason_strings = NULL; @@ -488,7 +489,7 @@ static int provider_activate(OSSL_PROVIDER *prov) /* Call the initialise function for the provider. */ if (prov->init_function == NULL || !prov->init_function(prov, core_dispatch, &provider_dispatch, - &prov->provctx)) { + &tmp_provctx)) { ERR_raise_data(ERR_LIB_CRYPTO, ERR_R_INIT_FAIL, NULL, "name=%s", prov->name); #ifndef FIPS_MODULE @@ -497,6 +498,7 @@ static int provider_activate(OSSL_PROVIDER *prov) #endif return 0; } + prov->provctx = tmp_provctx; for (; provider_dispatch->function_id != 0; provider_dispatch++) { switch (provider_dispatch->function_id) {