If the kernel build supports a FIPS module loader and FIPS mode is
enabled, we should not start tests or register /proc/crypto as this
will already have been done by the FIPS module.

Signed-off-by: Vegard Nossum <[email protected]>
---
 crypto/algapi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/crypto/algapi.c b/crypto/algapi.c
index e11b8fdb0865..09faecd47ea7 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -1105,6 +1105,14 @@ static void __init crypto_start_tests(void)
 
 static int __init crypto_algapi_init(void)
 {
+#if defined(CONFIG_CRYPTO_FIPS140_EXTMOD) && !defined(FIPS_MODULE)
+       /*
+        * The FIPS module will have done the initialization already.
+        */
+       if (fips_enabled)
+               return 0;
+#endif
+
        crypto_init_proc();
        crypto_start_tests();
        return 0;
-- 
2.39.3


Reply via email to