mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] crypto: tcrypt: stop ahash speed tests when setkey fails
@ 2026-03-03  0:06 Saeed Mirzamohammadi
  2026-03-14  5:11 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Saeed Mirzamohammadi @ 2026-03-03  0:06 UTC (permalink / raw)
  To: Herbert Xu, davem, ebiggers, saeed.mirzamohammadi, ardb, kees,
	linux-crypto, linux-kernel

The async hash speed path ignores the return code from
crypto_ahash_setkey().  If the caller picks an unsupported key length,
the transform keeps whatever key state it already has and the speed test
still runs, producing misleading numbers, hence bail out of the loop when
setkey fails.

Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
---
 crypto/tcrypt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 61c8cf55c4f1e..db860f45765fb 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -911,8 +911,14 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 			break;
 		}
 
-		if (klen)
-			crypto_ahash_setkey(tfm, tvmem[0], klen);
+		if (klen) {
+			ret = crypto_ahash_setkey(tfm, tvmem[0], klen);
+			if (ret) {
+				pr_err("setkey() failed flags=%x: %d\n",
+				       crypto_ahash_get_flags(tfm), ret);
+				break;
+			}
+		}
 
 		pr_info("test%3u "
 			"(%5u byte blocks,%5u bytes per update,%4u updates): ",
-- 
2.50.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: tcrypt: stop ahash speed tests when setkey fails
  2026-03-03  0:06 [PATCH] crypto: tcrypt: stop ahash speed tests when setkey fails Saeed Mirzamohammadi
@ 2026-03-14  5:11 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2026-03-14  5:11 UTC (permalink / raw)
  To: Saeed Mirzamohammadi
  Cc: davem, ebiggers, ardb, kees, linux-crypto, linux-kernel

On Mon, Mar 02, 2026 at 04:06:40PM -0800, Saeed Mirzamohammadi wrote:
> The async hash speed path ignores the return code from
> crypto_ahash_setkey().  If the caller picks an unsupported key length,
> the transform keeps whatever key state it already has and the speed test
> still runs, producing misleading numbers, hence bail out of the loop when
> setkey fails.
> 
> Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>
> ---
>  crypto/tcrypt.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
-- 
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-14  5:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-03  0:06 [PATCH] crypto: tcrypt: stop ahash speed tests when setkey fails Saeed Mirzamohammadi
2026-03-14  5:11 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®