]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: ahash - Stop legacy tfms from using the set_virt fallback path
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 13 Jun 2025 08:51:38 +0000 (16:51 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 23 Jun 2025 09:00:27 +0000 (17:00 +0800)
Ensure that drivers that have not been converted to the ahash API
do not use the ahash_request_set_virt fallback path as they cannot
use the software fallback.

Reported-by: Eric Biggers <ebiggers@kernel.org>
Fixes: 9d7a0ab1c753 ("crypto: ahash - Handle partial blocks in API")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/ahash.c
include/crypto/internal/hash.h

index bd9e49950201edb27f75ee420df71da95cc460a6..7a51e0cf9322b7e55350bb26a5327ed4c57a6d77 100644 (file)
@@ -350,6 +350,9 @@ static int ahash_do_req_chain(struct ahash_request *req,
        if (!crypto_ahash_need_fallback(tfm))
                return -ENOSYS;
 
+       if (crypto_hash_no_export_core(tfm))
+               return -ENOSYS;
+
        {
                u8 state[HASH_MAX_STATESIZE];
 
index 0f85c543f80bf497461a17c14e40daca8041f8b2..f052afa6e7b0c33e5be3df95c825f96d0ad44d4a 100644 (file)
@@ -91,6 +91,12 @@ static inline bool crypto_hash_alg_needs_key(struct hash_alg_common *alg)
                !(alg->base.cra_flags & CRYPTO_ALG_OPTIONAL_KEY);
 }
 
+static inline bool crypto_hash_no_export_core(struct crypto_ahash *tfm)
+{
+       return crypto_hash_alg_common(tfm)->base.cra_flags &
+              CRYPTO_AHASH_ALG_NO_EXPORT_CORE;
+}
+
 int crypto_grab_ahash(struct crypto_ahash_spawn *spawn,
                      struct crypto_instance *inst,
                      const char *name, u32 type, u32 mask);