From: Lukas Wunner <lukas@wunner.de>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
Eric Biggers <ebiggers@google.com>
Subject: Re: [v2 PATCH] Revert "crypto: run initcalls for generic implementations earlier"
Date: Thu, 5 Jun 2025 16:29:36 +0200 [thread overview]
Message-ID: <aEGp0MahOepfGpsm@wunner.de> (raw)
In-Reply-To: <aBHcftWYX1Pe9Ogh@gondor.apana.org.au>
On Wed, Apr 30, 2025 at 04:17:02PM +0800, Herbert Xu wrote:
> This reverts commit c4741b23059794bd99beef0f700103b0d983b3fd.
>
> Crypto API self-tests no longer run at registration time and now
> occur either at late_initcall or upon the first use.
>
> Therefore the premise of the above commit no longer exists. Revert
> it and subsequent additions of subsys_initcall and arch_initcall.
>
> Note that lib/crypto calls will stay at subsys_initcall (or rather
> downgraded from arch_initcall) because they may need to occur
> before Crypto API registration.
The above is now commit ef93f1562803 in Linus' tree.
For SHA3, the initcall change ended up in a different, unrelated commit,
0d474be2676d.
These changes break authentication of PCI devices upon their enumeration
because it happens in a subsys_initcall, whereas the generic asymmetric
and hash algorithms are now registered in a device_initcall, i.e. later.
PCI device authentication is not yet in mainline. I've provisionally
added the patch below to my development branch and can include it in
the next submission of the patches. The development branch is at:
https://github.com/l1k/linux/commits/doe
I just wanted to provide a heads-up and an opportunity for early feedback
to this patch.
Thanks!
Lukas
-- >8 --
Subject: [PATCH] crypto: Allow use of ECDSA, RSA, SHA2, SHA3 in
subsys_initcall
Commit ef93f1562803 ("Revert "crypto: run initcalls for generic
implementations earlier"") downgraded generic ECDSA, RSA, SHA2
to a device_initcall when built into the kernel proper.
Commit 0d474be2676d ("crypto: sha3-generic - Use API partial block
handling") did the same for generic SHA3.
To be able to authenticate PCI devices upon enumeration, move them back
to subsys_initcall level (which is when PCI device enumeration happens).
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
crypto/algboss.c | 2 +-
crypto/ecdsa.c | 2 +-
crypto/rsa.c | 2 +-
crypto/sha256.c | 2 +-
crypto/sha3_generic.c | 2 +-
crypto/sha512_generic.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/crypto/algboss.c b/crypto/algboss.c
index 846f586..74517f2 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -247,7 +247,7 @@ static void __exit cryptomgr_exit(void)
BUG_ON(err);
}
-module_init(cryptomgr_init);
+subsys_initcall(cryptomgr_init);
module_exit(cryptomgr_exit);
MODULE_LICENSE("GPL");
diff --git a/crypto/ecdsa.c b/crypto/ecdsa.c
index ce8e4364..a70b60a 100644
--- a/crypto/ecdsa.c
+++ b/crypto/ecdsa.c
@@ -334,7 +334,7 @@ static void __exit ecdsa_exit(void)
crypto_unregister_sig(&ecdsa_nist_p521);
}
-module_init(ecdsa_init);
+subsys_initcall(ecdsa_init);
module_exit(ecdsa_exit);
MODULE_LICENSE("GPL");
diff --git a/crypto/rsa.c b/crypto/rsa.c
index 6c77340..b7d2152 100644
--- a/crypto/rsa.c
+++ b/crypto/rsa.c
@@ -430,7 +430,7 @@ static void __exit rsa_exit(void)
crypto_unregister_akcipher(&rsa);
}
-module_init(rsa_init);
+subsys_initcall(rsa_init);
module_exit(rsa_exit);
MODULE_ALIAS_CRYPTO("rsa");
MODULE_LICENSE("GPL");
diff --git a/crypto/sha256.c b/crypto/sha256.c
index 4aeb213..a20c920 100644
--- a/crypto/sha256.c
+++ b/crypto/sha256.c
@@ -264,7 +264,7 @@ static int __init crypto_sha256_mod_init(void)
num_algs -= 2;
return crypto_register_shashes(algs, ARRAY_SIZE(algs));
}
-module_init(crypto_sha256_mod_init);
+subsys_initcall(crypto_sha256_mod_init);
static void __exit crypto_sha256_mod_exit(void)
{
diff --git a/crypto/sha3_generic.c b/crypto/sha3_generic.c
index 41d1e50..47f5240 100644
--- a/crypto/sha3_generic.c
+++ b/crypto/sha3_generic.c
@@ -274,7 +274,7 @@ static void __exit sha3_generic_mod_fini(void)
crypto_unregister_shashes(algs, ARRAY_SIZE(algs));
}
-module_init(sha3_generic_mod_init);
+subsys_initcall(sha3_generic_mod_init);
module_exit(sha3_generic_mod_fini);
MODULE_LICENSE("GPL");
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
index 7368173..bfea65f 100644
--- a/crypto/sha512_generic.c
+++ b/crypto/sha512_generic.c
@@ -205,7 +205,7 @@ static void __exit sha512_generic_mod_fini(void)
crypto_unregister_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
}
-module_init(sha512_generic_mod_init);
+subsys_initcall(sha512_generic_mod_init);
module_exit(sha512_generic_mod_fini);
MODULE_LICENSE("GPL");
--
2.47.2
next prev parent reply other threads:[~2025-06-05 14:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 5:50 [PATCH 1/1] Revert "crypto: run initcalls for generic implementations earlier" Herbert Xu
2025-04-29 16:41 ` Eric Biggers
2025-04-30 2:21 ` Herbert Xu
2025-04-30 3:16 ` Eric Biggers
2025-04-30 3:18 ` Herbert Xu
2025-04-30 8:17 ` [v2 PATCH] " Herbert Xu
2025-04-30 17:52 ` Eric Biggers
2025-06-05 14:29 ` Lukas Wunner [this message]
2025-06-09 9:44 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aEGp0MahOepfGpsm@wunner.de \
--to=lukas@wunner.de \
--cc=ebiggers@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox