Skip to contentSkip to conversation

crypto: testmgr - add panic_on_fail module parameter

PATCH In review Eric Biggers 2 participants 2 messages Mar 31, 2019 – Apr 8, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: testmgr - add panic_on_fail module parameter

From: Eric Biggers <[email protected]>

Add a module parameter cryptomgr.panic_on_fail which causes the kernel to panic if any crypto self-tests fail.

Use cases:

- More easily detect crypto self-test failures by boot testing, e.g. on KernelCI.
- Get a bug report if syzkaller manages to use the template system to instantiate an algorithm that fails its self-tests.

The command-line option "fips=1" already does this, but it also makes other changes not wanted for general testing, such as disabling "unapproved" algorithms. panic_on_fail just does what it says.

---
 crypto/testmgr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
crypto/testmgr.c +6 -2
index 2c2ddebb48d37..0f6bfb6ce6a46 100644
@@ -45,6 +45,9 @@ static bool notests;
 module_param(notests, bool, 0644);
 MODULE_PARM_DESC(notests, "disable crypto self-tests");
 
+static bool panic_on_fail;
+module_param(panic_on_fail, bool, 0444);
+
 #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
 static bool noextratests;
 module_param(noextratests, bool, 0644);
@@ -4109,8 +4112,9 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
 					     type, mask);
 
 test_done:
-	if (fips_enabled && rc)
-		panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
+	if (rc && (fips_enabled || panic_on_fail))
+		panic("alg: self-tests for %s (%s) failed in %s mode!\n",
+		      driver, alg, fips_enabled ? "fips" : "panic_on_fail");
 
 	if (fips_enabled && !rc)
 		pr_info("alg: self-tests for %s (%s) passed\n", driver, alg);
Signature · 1 line
2.21.0
maintainer
#1 lore raw
Quoted 12 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Add a module parameter cryptomgr.panic_on_fail which causes the kernel to panic if any crypto self-tests fail.

Use cases:

- More easily detect crypto self-test failures by boot testing, e.g. on KernelCI.
- Get a bug report if syzkaller manages to use the template system to instantiate an algorithm that fails its self-tests.

Quoted 8 lines

The command-line option "fips=1" already does this, but it also makes other changes not wanted for general testing, such as disabling "unapproved" algorithms. panic_on_fail just does what it says.

---
 crypto/testmgr.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt