]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
fips provider: explicitly setup cpuid when initializing
authorHongren Zheng <i@zenithal.me>
Thu, 16 May 2024 08:41:25 +0000 (16:41 +0800)
committerTomas Mraz <tomas@openssl.org>
Mon, 20 May 2024 08:14:39 +0000 (10:14 +0200)
Fixes: #23979
Previously fips module relied on OPENSSL_cpuid_setup
being used as constructor by the linker to correctly
setup the capability vector, either via .section .init
(for x86_64) or via __attribute__((constructor)).

This would make ld.so call OPENSSL_cpuid_setup before
the init function for fips module. However, this early
constructing behavior has several disadvantages:

1. Not all platform/toolchain supports such behavior

2. Initialisation sequence is not well defined, and
some function might not be initialized when cpuid_setup
is called

3. Implicit path is hard to maintain and debug

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24419)

providers/fips/fipsprov.c

index 1f36ce63932b0acca8afcb455d5fcea0a38d7a57..0174c6b33b41d2a717d73168e560eb00bbb2aa09 100644 (file)
@@ -695,6 +695,8 @@ int OSSL_provider_init_int(const OSSL_CORE_HANDLE *handle,
         }
     }
 
+    OPENSSL_cpuid_setup();
+
     /*  Create a context. */
     if ((*provctx = ossl_prov_ctx_new()) == NULL
             || (libctx = OSSL_LIB_CTX_new()) == NULL)