From: Antonio Quartulli <antonio@mandelbit.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
Steffen Klassert <steffen.klassert@secunet.com>
Cc: Antonio Quartulli <antonio@mandelbit.com>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] crypto: pcrypt - Refuse to wrap a pcrypt instance
Date: Tue, 24 Nov 2026 14:24:41 +0100 [thread overview]
Message-ID: <20261124132443.3666372-1-antonio@mandelbit.com> (raw)
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
reply other threads:[~2026-11-24 13:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261124132443.3666372-1-antonio@mandelbit.com \
--to=antonio@mandelbit.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
/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