Skip to content

Commit c4741b2

Browse files
ebiggersherbertx
authored andcommitted
crypto: run initcalls for generic implementations earlier
Use subsys_initcall for registration of all templates and generic algorithm implementations, rather than module_init. Then change cryptomgr to use arch_initcall, to place it before the subsys_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 <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 40153b1 commit c4741b2

83 files changed

Lines changed: 89 additions & 83 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎crypto/842.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static int __init crypto842_mod_init(void)
144144

145145
return ret;
146146
}
147-
module_init(crypto842_mod_init);
147+
subsys_initcall(crypto842_mod_init);
148148

149149
static void __exit crypto842_mod_exit(void)
150150
{

‎crypto/adiantum.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static void __exit adiantum_module_exit(void)
659659
crypto_unregister_template(&adiantum_tmpl);
660660
}
661661

662-
module_init(adiantum_module_init);
662+
subsys_initcall(adiantum_module_init);
663663
module_exit(adiantum_module_exit);
664664

665665
MODULE_DESCRIPTION("Adiantum length-preserving encryption mode");

‎crypto/aegis128.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static void __exit crypto_aegis128_module_exit(void)
448448
crypto_unregister_aead(&crypto_aegis128_alg);
449449
}
450450

451-
module_init(crypto_aegis128_module_init);
451+
subsys_initcall(crypto_aegis128_module_init);
452452
module_exit(crypto_aegis128_module_exit);
453453

454454
MODULE_LICENSE("GPL");

‎crypto/aegis128l.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static void __exit crypto_aegis128l_module_exit(void)
512512
crypto_unregister_aead(&crypto_aegis128l_alg);
513513
}
514514

515-
module_init(crypto_aegis128l_module_init);
515+
subsys_initcall(crypto_aegis128l_module_init);
516516
module_exit(crypto_aegis128l_module_exit);
517517

518518
MODULE_LICENSE("GPL");

‎crypto/aegis256.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static void __exit crypto_aegis256_module_exit(void)
463463
crypto_unregister_aead(&crypto_aegis256_alg);
464464
}
465465

466-
module_init(crypto_aegis256_module_init);
466+
subsys_initcall(crypto_aegis256_module_init);
467467
module_exit(crypto_aegis256_module_exit);
468468

469469
MODULE_LICENSE("GPL");

‎crypto/aes_generic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ static void __exit aes_fini(void)
14701470
crypto_unregister_alg(&aes_alg);
14711471
}
14721472

1473-
module_init(aes_init);
1473+
subsys_initcall(aes_init);
14741474
module_exit(aes_fini);
14751475

14761476
MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm");

‎crypto/algboss.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ static void __exit cryptomgr_exit(void)
296296
BUG_ON(err);
297297
}
298298

299-
subsys_initcall(cryptomgr_init);
299+
/*
300+
* This is arch_initcall() so that the crypto self-tests are run on algorithms
301+
* registered early by subsys_initcall(). subsys_initcall() is needed for
302+
* generic implementations so that they're available for comparison tests when
303+
* other implementations are registered later by module_init().
304+
*/
305+
arch_initcall(cryptomgr_init);
300306
module_exit(cryptomgr_exit);
301307

302308
MODULE_LICENSE("GPL");

‎crypto/ansi_cprng.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ MODULE_DESCRIPTION("Software Pseudo Random Number Generator");
472472
MODULE_AUTHOR("Neil Horman <nhorman@tuxdriver.com>");
473473
module_param(dbg, int, 0);
474474
MODULE_PARM_DESC(dbg, "Boolean to enable debugging (0/1 == off/on)");
475-
module_init(prng_mod_init);
475+
subsys_initcall(prng_mod_init);
476476
module_exit(prng_mod_fini);
477477
MODULE_ALIAS_CRYPTO("stdrng");
478478
MODULE_ALIAS_CRYPTO("ansi_cprng");

‎crypto/anubis.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static void __exit anubis_mod_fini(void)
699699
crypto_unregister_alg(&anubis_alg);
700700
}
701701

702-
module_init(anubis_mod_init);
702+
subsys_initcall(anubis_mod_init);
703703
module_exit(anubis_mod_fini);
704704

705705
MODULE_LICENSE("GPL");

‎crypto/arc4.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static void __exit arc4_exit(void)
163163
crypto_unregister_skcipher(&arc4_skcipher);
164164
}
165165

166-
module_init(arc4_init);
166+
subsys_initcall(arc4_init);
167167
module_exit(arc4_exit);
168168

169169
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)