* [PATCH] crypto: simd - reject compat registrations without __ prefixes
@ 2026-03-09 4:31 Wesley Atwell
2026-03-21 8:41 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Wesley Atwell @ 2026-03-09 4:31 UTC (permalink / raw)
To: herbert, davem, ebiggers; +Cc: linux-crypto, linux-kernel, Wesley Atwell
simd_register_skciphers_compat() and simd_register_aeads_compat()
derive the wrapper algorithm names by stripping the __ prefix from the
internal algorithm names.
Currently they only WARN if cra_name or cra_driver_name lacks that prefix,
but they still continue and unconditionally add 2 to both strings. That
registers wrapper algorithms with incorrectly truncated names after a
violated precondition.
Reject such inputs with -EINVAL before registering anything, while keeping
the warning so invalid internal API usage is still visible.
Fixes: d14f0a1fc488 ("crypto: simd - allow registering multiple algorithms at once")
Fixes: 1661131a0479 ("crypto: simd - support wrapping AEAD algorithms")
Assisted-by: Codex:GPT-5
Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
---
crypto/simd.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/crypto/simd.c b/crypto/simd.c
index f71c4a334c7d..4e6f437e9e77 100644
--- a/crypto/simd.c
+++ b/crypto/simd.c
@@ -214,13 +214,17 @@ int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
const char *basename;
struct simd_skcipher_alg *simd;
+ for (i = 0; i < count; i++) {
+ if (WARN_ON(strncmp(algs[i].base.cra_name, "__", 2) ||
+ strncmp(algs[i].base.cra_driver_name, "__", 2)))
+ return -EINVAL;
+ }
+
err = crypto_register_skciphers(algs, count);
if (err)
return err;
for (i = 0; i < count; i++) {
- WARN_ON(strncmp(algs[i].base.cra_name, "__", 2));
- WARN_ON(strncmp(algs[i].base.cra_driver_name, "__", 2));
algname = algs[i].base.cra_name + 2;
drvname = algs[i].base.cra_driver_name + 2;
basename = algs[i].base.cra_driver_name;
@@ -437,13 +441,17 @@ int simd_register_aeads_compat(struct aead_alg *algs, int count,
const char *basename;
struct simd_aead_alg *simd;
+ for (i = 0; i < count; i++) {
+ if (WARN_ON(strncmp(algs[i].base.cra_name, "__", 2) ||
+ strncmp(algs[i].base.cra_driver_name, "__", 2)))
+ return -EINVAL;
+ }
+
err = crypto_register_aeads(algs, count);
if (err)
return err;
for (i = 0; i < count; i++) {
- WARN_ON(strncmp(algs[i].base.cra_name, "__", 2));
- WARN_ON(strncmp(algs[i].base.cra_driver_name, "__", 2));
algname = algs[i].base.cra_name + 2;
drvname = algs[i].base.cra_driver_name + 2;
basename = algs[i].base.cra_driver_name;
base-commit: 1f318b96cc84d7c2ab792fcc0bfd42a7ca890681
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] crypto: simd - reject compat registrations without __ prefixes
2026-03-09 4:31 [PATCH] crypto: simd - reject compat registrations without __ prefixes Wesley Atwell
@ 2026-03-21 8:41 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-03-21 8:41 UTC (permalink / raw)
To: Wesley Atwell; +Cc: davem, ebiggers, linux-crypto, linux-kernel
On Sun, Mar 08, 2026 at 10:31:43PM -0600, Wesley Atwell wrote:
> simd_register_skciphers_compat() and simd_register_aeads_compat()
> derive the wrapper algorithm names by stripping the __ prefix from the
> internal algorithm names.
>
> Currently they only WARN if cra_name or cra_driver_name lacks that prefix,
> but they still continue and unconditionally add 2 to both strings. That
> registers wrapper algorithms with incorrectly truncated names after a
> violated precondition.
>
> Reject such inputs with -EINVAL before registering anything, while keeping
> the warning so invalid internal API usage is still visible.
>
> Fixes: d14f0a1fc488 ("crypto: simd - allow registering multiple algorithms at once")
> Fixes: 1661131a0479 ("crypto: simd - support wrapping AEAD algorithms")
> Assisted-by: Codex:GPT-5
> Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
> ---
> crypto/simd.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-21 8:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 4:31 [PATCH] crypto: simd - reject compat registrations without __ prefixes Wesley Atwell
2026-03-21 8:41 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox