From: Bruno Meneguele <bmeneg@redhat.com>
To: linux-crypto@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, herbert@gondor.apana.org.au,
davem@davemloft.net, ebiggers@google.com,
Bruno Meneguele <bmeneg@redhat.com>,
stable@vger.kernel.org
Subject: [PATCH] crypto: cmac,xcbc,ccm - accept CRYPTO_ALG_REQ_VIRT in template type check
Date: Thu, 3 Dec 2026 18:01:19 -0300 [thread overview]
Message-ID: <20261203210119.42352-1-bmeneg@redhat.com> (raw)
Since commit 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API"),
crypto_ahash_init_tfm() allocates a fallback for every async driver by setting
CRYPTO_ALG_REQ_VIRT flag in both type and mask.
However, the cmac, xcbc and cbcmac templates validate the request with:
crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask)
which compares the whole flag word, including the previously set
CRYPTO_ALG_REQ_VIRT flag, which is now missing during comparison, causing it to
return -EINVAL.
The error propagates to crypto_ahash_init_tfm(), even before a driver's own init
runs, causing the driver to fail on its self-test. For instance, on NVIDIA
Tegra:
alg: hash: failed to allocate transform for tegra-se-cmac: -22
alg: self-tests for cmac(aes) using tegra-se-cmac failed (rc=-22)
With this commit these templates pass CRYPTO_ALG_TYPE_SHASH|CRYPTO_ALG_REQ_VIRT
instead, so requests that need REQ_VIRT set are accepted, and requests that need
it clear, are still rejected.
Fixes: 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API")
Cc: stable@vger.kernel.org
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
---
crypto/ccm.c | 3 ++-
crypto/cmac.c | 3 ++-
crypto/xcbc.c | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/crypto/ccm.c b/crypto/ccm.c
index 916441e4f2b8..250af56cfe1f 100644
--- a/crypto/ccm.c
+++ b/crypto/ccm.c
@@ -852,7 +852,8 @@ static int cbcmac_create(struct crypto_template *tmpl, struct rtattr **tb)
u32 mask;
int err;
- err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask);
+ err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH |
+ CRYPTO_ALG_REQ_VIRT, &mask);
if (err)
return err;
diff --git a/crypto/cmac.c b/crypto/cmac.c
index 83e58937f013..74786612a6f1 100644
--- a/crypto/cmac.c
+++ b/crypto/cmac.c
@@ -165,7 +165,8 @@ static int cmac_create(struct crypto_template *tmpl, struct rtattr **tb)
u32 mask;
int err;
- err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask);
+ err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH |
+ CRYPTO_ALG_REQ_VIRT, &mask);
if (err)
return err;
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 6c5f6766fdd6..50f14bd7d88d 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -132,7 +132,8 @@ static int xcbc_create(struct crypto_template *tmpl, struct rtattr **tb)
u32 mask;
int err;
- err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH, &mask);
+ err = crypto_check_attr_type(tb, CRYPTO_ALG_TYPE_SHASH |
+ CRYPTO_ALG_REQ_VIRT, &mask);
if (err)
return err;
--
2.55.0
reply other threads:[~2026-12-03 21:01 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=20261203210119.42352-1-bmeneg@redhat.com \
--to=bmeneg@redhat.com \
--cc=davem@davemloft.net \
--cc=ebiggers@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@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