Re: [PATCH] crypto: marvell/cesa - Avoid empty transfer descriptor

Herbert Xu
2025-05-13T09:20:12Z

On Sun, May 11, 2025 at 06:39:43PM +0200, Klaus Kudielka wrote:
>
> Here the log after modprobe, with the new printk patch:

Thanks. I'm starting to get the feeling that the partial hash
is corrupted.

Please apply this patch on top of the printk patch to confirm this.

Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/drivers/crypto/marvell/cesa/hash.c b/drivers/crypto/marvell/cesa/hash.c
index 6815eddc9068..230501fe843b 100644
--- a/drivers/crypto/marvell/cesa/hash.c
+++ b/drivers/crypto/marvell/cesa/hash.c
@@ -374,6 +374,12 @@ static void mv_cesa_ahash_complete(struct crypto_async_request *req)

memcpy(ahashreq->result, data, digsize);
} else {
+ struct {
+ u32 digest[8];
+ u64 len;
+ } state;
+
+ memcpy(state.digest, creq->state, digsize);
for (i = 0; i < digsize / 4; i++)
creq->state[i] = readl_relaxed(engine->regs +
CESA_IVDIG(i));
@@ -393,6 +399,21 @@ static void mv_cesa_ahash_complete(struct crypto_async_request *req)
for (i = 0; i < digsize / 4; i++)
result[i] = cpu_to_be32(creq->state[i]);
}
+ } else {
+ HASH_FBREQ_ON_STACK(fbreq, ahashreq);
+
+ crypto_ahash_import_core(fbreq, &state);
+ crypto_ahash_update(fbreq);
+ crypto_ahash_export_core(fbreq, &state);
+ if (memcmp(state.digest, creq->state, digsize)) {
+ pr_err("mv_cesa_ahash_complete partial hash mismatch\n");
+ print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ state.digest, digsize, false);
+ print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ creq->state, digsize, false);
+ }
}
}