[PATCH] crypto: cmac,xcbc,ccm - accept CRYPTO_ALG_REQ_VIRT in template type check
From: Bruno Meneguele
Date: Thu Dec 03 2026 - 16:01:41 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Bruno Meneguele <bmeneg@xxxxxxxxxx>
---
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