]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
crypto: testmgr - WARN on test failure
authorEric Biggers <ebiggers@google.com>
Mon, 26 Oct 2020 16:31:12 +0000 (09:31 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 6 Nov 2020 03:29:10 +0000 (14:29 +1100)
Currently, by default crypto self-test failures only result in a
pr_warn() message and an "unknown" status in /proc/crypto.  Both of
these are easy to miss.  There is also an option to panic the kernel
when a test fails, but that can't be the default behavior.

A crypto self-test failure always indicates a kernel bug, however, and
there's already a standard way to report (recoverable) kernel bugs --
the WARN() family of macros.  WARNs are noisier and harder to miss, and
existing test systems already know to look for them in dmesg or via
/proc/sys/kernel/tainted.

Therefore, call WARN() when an algorithm fails its self-tests.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c

index dcc1fa415e8e00b3e5d58ef78fbd81289fd94b24..321e38eef51bc52296524b945b2b802d05d5443d 100644 (file)
@@ -5664,15 +5664,21 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
                                             type, mask);
 
 test_done:
-       if (rc && (fips_enabled || panic_on_fail)) {
-               fips_fail_notify();
-               panic("alg: self-tests for %s (%s) failed in %s mode!\n",
-                     driver, alg, fips_enabled ? "fips" : "panic_on_fail");
+       if (rc) {
+               if (fips_enabled || panic_on_fail) {
+                       fips_fail_notify();
+                       panic("alg: self-tests for %s (%s) failed in %s mode!\n",
+                             driver, alg,
+                             fips_enabled ? "fips" : "panic_on_fail");
+               }
+               WARN(1, "alg: self-tests for %s (%s) failed (rc=%d)",
+                    driver, alg, rc);
+       } else {
+               if (fips_enabled)
+                       pr_info("alg: self-tests for %s (%s) passed\n",
+                               driver, alg);
        }
 
-       if (fips_enabled && !rc)
-               pr_info("alg: self-tests for %s (%s) passed\n", driver, alg);
-
        return rc;
 
 notest: