* [PATCH] crypto: pcrypt - Refuse to wrap a pcrypt instance
@ 2026-11-24 13:24 Antonio Quartulli
0 siblings, 0 replies; only message in thread
From: Antonio Quartulli @ 2026-11-24 13:24 UTC (permalink / raw)
To: Herbert Xu, Steffen Klassert
Cc: Antonio Quartulli, David S. Miller, linux-crypto, stable
A pcrypt instance keeps the cra_name of the algorithm it wraps. When
pcrypt is requested with a generic inner name, the new instance cannot
be found by the requested name, so the request is retried and the next
instance wraps the previous one, now the highest-priority match. Each
retry adds a nesting level until the driver name overflows.
Nesting pcrypt is pointless, so refuse it.
Fixes: 5068c7a883d1 ("crypto: pcrypt - Add pcrypt crypto parallelization wrapper")
Cc: stable@vger.kernel.org
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
Found while enabling pcrypt for rfc7539(chacha20,poly1305) on 6.18: an
AF_ALG bind of "pcrypt(rfc7539(chacha20,poly1305))" left 11 nested
instances and failed with -ENAMETOOLONG. On v7.4-rc4 the same happens
through crypto_user: each CRYPTO_MSG_NEWALG for that name adds a level.
With this patch only one instance is created.
crypto/pcrypt.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
index 9f372442981e..d2acc64bcee3 100644
--- a/crypto/pcrypt.c
+++ b/crypto/pcrypt.c
@@ -271,6 +271,15 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb,
goto err_free_inst;
alg = crypto_spawn_aead_alg(&ctx->spawn);
+
+ /*
+ * A pcrypt instance keeps the cra_name of the algorithm it wraps, so
+ * the inner lookup can return an existing pcrypt instance. Do not nest.
+ */
+ err = -EEXIST;
+ if (strstarts(alg->base.cra_driver_name, "pcrypt("))
+ goto err_free_inst;
+
err = pcrypt_init_instance(aead_crypto_instance(inst), &alg->base);
if (err)
goto err_free_inst;
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-24 13:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:24 [PATCH] crypto: pcrypt - Refuse to wrap a pcrypt instance Antonio Quartulli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox