Skip to content

Commit eda69b0

Browse files
ebiggersherbertx
authored andcommitted
crypto: testmgr - add panic_on_fail module parameter
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. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent f6e9af8 commit eda69b0

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎crypto/testmgr.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ static bool notests;
4545
module_param(notests, bool, 0644);
4646
MODULE_PARM_DESC(notests, "disable crypto self-tests");
4747

48+
static bool panic_on_fail;
49+
module_param(panic_on_fail, bool, 0444);
50+
4851
#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
4952
static bool noextratests;
5053
module_param(noextratests, bool, 0644);
@@ -4109,8 +4112,9 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
41094112
type, mask);
41104113

41114114
test_done:
4112-
if (fips_enabled && rc)
4113-
panic("%s: %s alg self test failed in fips mode!\n", driver, alg);
4115+
if (rc && (fips_enabled || panic_on_fail))
4116+
panic("alg: self-tests for %s (%s) failed in %s mode!\n",
4117+
driver, alg, fips_enabled ? "fips" : "panic_on_fail");
41144118

41154119
if (fips_enabled && !rc)
41164120
pr_info("alg: self-tests for %s (%s) passed\n", driver, alg);

0 commit comments

Comments
 (0)