crypto: api - Fix boot-up self-test race

BugLink: https://bugs.launchpad.net/bugs/2111953

[ Upstream commit 8dd458cbc5be9ce4427ffce7a9dcdbff4dfc4ac9 ]

During the boot process self-tests are postponed so that all
algorithms are registered when the test starts.  In the event
that algorithms are still being registered during these tests,
which can occur either because the algorithm is registered at
late_initcall, or because a self-test itself triggers the creation
of an instance, some self-tests may never start at all.

Fix this by setting the flag at the start of crypto_start_tests.

Note that this race is theoretical and has never been observed
in practice.

Fixes: adad556efc ("crypto: api - Fix built-in testing dependency failures")
Signed-off-by: Herbert Xu <herbert.xu@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com>
Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
This commit is contained in:
Herbert Xu
2024-11-15 09:29:02 +08:00
committed by Mehmet Basaran
parent 0ea0533559
commit 3560b308e4
+2 -2
View File
@@ -1059,6 +1059,8 @@ static void __init crypto_start_tests(void)
if (IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS))
return;
set_crypto_boot_test_finished();
for (;;) {
struct crypto_larval *larval = NULL;
struct crypto_alg *q;
@@ -1091,8 +1093,6 @@ static void __init crypto_start_tests(void)
crypto_wait_for_test(larval);
}
set_crypto_boot_test_finished();
}
static int __init crypto_algapi_init(void)