From: Eric Biggers <ebiggers@kernel.org>
To: Bruno Meneguele <bmeneg@redhat.com>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
herbert@gondor.apana.org.au, davem@davemloft.net,
stable@vger.kernel.org
Subject: Re: [PATCH] crypto: cmac,xcbc,ccm - accept CRYPTO_ALG_REQ_VIRT in template type check
Date: Thu, 3 Dec 2026 21:18:16 +0000 [thread overview]
Message-ID: <20261203211816.GA601100@google.com> (raw)
In-Reply-To: <20261203210119.42352-1-bmeneg@redhat.com>
On Thu, Dec 03, 2026 at 06:01:19PM -0300, Bruno Meneguele wrote:
> 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(-)
The "Handle partial blocks in API" design is still a bit perplexing to
me. But I *think* a better for this issue would actually be
crypto_check_attr_type() itself:
if (type == CRYPTO_ALG_TYPE_SHASH || type == CRYPTO_ALG_TYPE_SCOMPRESS)
type |= CRYPTO_ALG_REQ_VIRT;
That would be consistent with the documentation for
crypto_check_attr_type()'s type parameter, which says it's the algorithm
type. It doesn't say that you can pass other flags too. It would also
ensure that other templates like hmac-shash aren't missed.
Of course, if we take a step back, this issue also makes it clear that
~6 drivers in drivers/crypto/ (the ones that register one of the
affected algorithms) haven't been tested in the last 18 months. Such
untested crypto drivers do not belong in the kernel in the first place.
- Eric
next prev parent reply other threads:[~2026-12-03 21:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 21:01 [PATCH] crypto: cmac,xcbc,ccm - accept CRYPTO_ALG_REQ_VIRT in template type check Bruno Meneguele
2026-12-03 21:18 ` Eric Biggers [this message]
2026-12-03 21:36 ` Bruno Meneguele
2026-12-03 21:21 ` sashiko-bot
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=20261203211816.GA601100@google.com \
--to=ebiggers@kernel.org \
--cc=bmeneg@redhat.com \
--cc=davem@davemloft.net \
--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