crypto: run initcalls for generic implementations earlier
A message that is not in the archive (sent off-list or not yet received): git-mailbomb-linux-master-c4741b23059794bd99beef0f700103b0d983b3fd@kernel.org
Hi Eric,
Quoted 32 lines · Linux Kernel Mailing List
Commit: c4741b23059794bd99beef0f700103b0d983b3fd Parent: 40153b10d91c9e25f912344ba6ce1f0874400659 Refname: refs/heads/master Web: https://git.kernel.org/torvalds/c/c4741b23059794bd99beef0f700103b0d983b3fd Author: Eric Biggers <[email protected]> AuthorDate: Thu Apr 11 21:57:42 2019 -0700 Committer: Herbert Xu <[email protected]> CommitDate: Thu Apr 18 22:15:03 2019 +0800crypto: run initcalls for generic implementations earlier
Use
subsys_initcallfor registration of all templates and generic algorithm implementations, rather thanmodule_init. Then change cryptomgr to usearch_initcall, to place it before thesubsys_initcalls.This is needed so that when both a generic and optimized implementation of an algorithm are built into the kernel (not loadable modules), the generic implementation is registered before the optimized one. Otherwise, the self-tests for the optimized implementation are unable to allocate the generic implementation for the new comparison fuzz tests.
Note that on arm, a side effect of this change is that self-tests for generic implementations may run before the unaligned access handler has been installed. So, unaligned accesses will crash the kernel. This is arguably a good thing as it makes it easier to detect that type of bug.
Signed-off-by Eric Biggers <[email protected]>Signed-off-by Herbert Xu <[email protected]>
crypto/jitterentropy-kcapi.c static void __exit jent_mod_exit(void) · line 204
Quoted 8 lines
crypto/jitterentropy-kcapi.c +1
-1@@ -198,7 +198,7 @@ static void __exit jent_mod_exit(void)crypto_unregister_rng (&jent_alg); } -module_init (jent_mod_init); +subsys_initcall (jent_mod_init);module_exit (jent_mod_exit);MODULE_LICENSE ("Dual BSD/GPL" );
This change causes jitterentropy to fail on Renesas SoCs based on single-core Cortex A9 with:
jitterentropy: Initialization failed with host not compliant with
requirements: 2
This happens because jitterentropy is now initialized before the main clocksource is activated, i.e. before
clocksource: Switched to clocksource ostm timer (on RZ/A1)
clocksource: Switched to clocksource fff80000.timer (on R-Mobile A1)
is printed.
RZ/A1 and R-Mobile A1 SoCs rely on the OSTM resp. TMU timers.
The issue does not happen on SoCs with Cortex A15 cores (with ARM architectured timer) or Cortex A9 multicore (with ARM global timer).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 60 lines · Geert Uytterhoeven
Hi Eric,
Quoted 32 lines · Linux Kernel Mailing List
Commit: c4741b23059794bd99beef0f700103b0d983b3fd Parent: 40153b10d91c9e25f912344ba6ce1f0874400659 Refname: refs/heads/master Web: https://git.kernel.org/torvalds/c/c4741b23059794bd99beef0f700103b0d983b3fd Author: Eric Biggers <[email protected]> AuthorDate: Thu Apr 11 21:57:42 2019 -0700 Committer: Herbert Xu <[email protected]> CommitDate: Thu Apr 18 22:15:03 2019 +0800crypto: run initcalls for generic implementations earlier
Use
subsys_initcallfor registration of all templates and generic algorithm implementations, rather thanmodule_init. Then change cryptomgr to usearch_initcall, to place it before thesubsys_initcalls.This is needed so that when both a generic and optimized implementation of an algorithm are built into the kernel (not loadable modules), the generic implementation is registered before the optimized one. Otherwise, the self-tests for the optimized implementation are unable to allocate the generic implementation for the new comparison fuzz tests.
Note that on arm, a side effect of this change is that self-tests for generic implementations may run before the unaligned access handler has been installed. So, unaligned accesses will crash the kernel. This is arguably a good thing as it makes it easier to detect that type of bug.
Signed-off-by Eric Biggers <[email protected]>Signed-off-by Herbert Xu <[email protected]>crypto/jitterentropy-kcapi.c static void __exit jent_mod_exit(void) · line 204
Quoted 8 lines
crypto/jitterentropy-kcapi.c +1
-1@@ -198,7 +198,7 @@ static void __exit jent_mod_exit(void)crypto_unregister_rng (&jent_alg); } -module_init (jent_mod_init); +subsys_initcall (jent_mod_init);module_exit (jent_mod_exit);MODULE_LICENSE ("Dual BSD/GPL" );This change causes jitterentropy to fail on Renesas SoCs based on single-core Cortex A9 with:
jitterentropy: Initialization failed with host not compliant with
requirements: 2This happens because jitterentropy is now initialized before the main clocksource is activated, i.e. before
clocksource: Switched to clocksource ostm timer (on RZ/A1)
clocksource: Switched to clocksource fff80000.timer (on R-Mobile A1)is printed.
RZ/A1 and R-Mobile A1 SoCs rely on the OSTM resp. TMU timers.
Quoted 7 lines
The issue does not happen on SoCs with Cortex A15 cores (with ARM architectured timer) or Cortex A9 multicore (with ARM global timer).
Gr{oetje,eeting}s,
Geert
Thanks for the bug report. It seems there was no point for my patch to change jitterentropy_rng, since it's not a generic crypto algorithm that has multiple implementations, nor is it testable by the crypto self-tests. So I'll send a patch that changes it back to module_init().
- Eric
PATCH 1/1 crypto: jitterentropy - change back to module_init()
From: Eric Biggers <[email protected]>
"jitterentropy_rng" doesn't have any other implementations, nor is it tested by the crypto self-tests. So it was unnecessary to change it to subsys_initcall. Also it depends on the main clocksource being initialized, which may happen after subsys_initcall, causing this error:
jitterentropy: Initialization failed with host not compliant with requirements: 2
Change it back to module_init().
--- crypto/jitterentropy-kcapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/jitterentropy-kcapi.c +1 -1
@@ -198,7 +198,7 @@ static void __exit jent_mod_exit(void)crypto_unregister_rng (&jent_alg); } -subsys_initcall (jent_mod_init); +module_init (jent_mod_init);module_exit (jent_mod_exit);MODULE_LICENSE ("Dual BSD/GPL" );
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog
Re: [PATCH] crypto: jitterentropy - change back to module_init()
Quoted 7 lines · Eric Biggers
From: Eric Biggers <[email protected]>
"
jitterentropy_rng" doesn't have any other implementations, nor is it tested by the crypto self-tests. So it was unnecessary to change it tosubsys_initcall. Also it depends on the main clocksource being initialized, which may happen aftersubsys_initcall, causing this error:
Quoted 7 lines
jitterentropy: Initialization failed with host not compliant with requirements: 2
Change it back to
module_init().Fixes c4741b230597 ("crypto: run initcalls for generic implementations earlier")Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Eric Biggers <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Herbert Xu
maintainerRe: [PATCH] crypto: jitterentropy - change back to module_init()
In reply to Eric BiggersQuoted 9 lines · Eric Biggers
From: Eric Biggers <[email protected]>
"
jitterentropy_rng" doesn't have any other implementations, nor is it tested by the crypto self-tests. So it was unnecessary to change it tosubsys_initcall. Also it depends on the main clocksource being initialized, which may happen aftersubsys_initcall, causing this error:jitterentropy: Initialization failed with host not compliant with requirements: 2
Quoted 8 lines
Change it back to
module_init().Fixes c4741b230597 ("crypto: run initcalls for generic implementations earlier")Reported-by Geert Uytterhoeven <[email protected]>Signed-off-by Eric Biggers <[email protected]>--- crypto/jitterentropy-kcapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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