From: Artem Novak <artem122novak@gmail.com>
To: herbert@gondor.apana.org.au, davem@davemloft.net
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Artem Novak <artem122novak@gmail.com>
Subject: [PATCH v2] crypto: tcrypt: avoid 32-bit overflow in throughput calculation
Date: Thu, 26 Nov 2026 00:05:48 -0600 [thread overview]
Message-ID: <20261126060548.24746-1-artem122novak@gmail.com> (raw)
In-Reply-To: <20261126055600.23172-1-artem122novak@gmail.com>
Cast bcount to u64 before multiplying by blen to prevent 32-bit
overflow when calculating throughput on 32-bit architectures.
Fixes: beb63da739f7 ("crypto: tcrypt - Add speed tests for async hashing")
Signed-off-by: Artem Novak <artem122novak@gmail.com>
---
crypto/tcrypt.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index e6834bdde9b9..1e6132045c24 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -28,6 +28,7 @@
#include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
+#include <linux/math64.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/scatterlist.h>
@@ -734,6 +735,7 @@ static int test_ahash_jiffies_digest(struct tcrypt_ahash_request *treq,
{
struct ahash_request *req = treq->req;
unsigned long start, end;
+ u64 bytes;
int bcount;
int ret;
@@ -744,8 +746,9 @@ static int test_ahash_jiffies_digest(struct tcrypt_ahash_request *treq,
return ret;
}
- pr_cont("%6u opers/sec, %9lu bytes/sec\n",
- bcount / secs, ((long)bcount * blen) / secs);
+ bytes = div_u64((u64)bcount * blen, secs);
+ pr_cont("%6u opers/sec, %9llu bytes/sec\n",
+ bcount / secs, (unsigned long long)bytes);
return 0;
}
@@ -755,6 +758,7 @@ static int test_ahash_jiffies(struct tcrypt_ahash_request *treq, int blen,
{
struct ahash_request *req = treq->req;
unsigned long start, end;
+ u64 bytes;
int bcount, pcount;
int ret;
@@ -777,8 +781,9 @@ static int test_ahash_jiffies(struct tcrypt_ahash_request *treq, int blen,
return ret;
}
- pr_cont("%6u opers/sec, %9lu bytes/sec\n",
- bcount / secs, ((long)bcount * blen) / secs);
+ bytes = div_u64((u64)bcount * blen, secs);
+ pr_cont("%6u opers/sec, %9llu bytes/sec\n",
+ bcount / secs, (unsigned long long)bytes);
return 0;
}
--
2.56.1
next prev parent reply other threads:[~2026-11-26 6:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 5:56 [PATCH] " Artem Novak
2026-11-26 6:05 ` Artem Novak [this message]
2026-11-26 6:14 ` [PATCH v2] " Artem Novak
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=20261126060548.24746-1-artem122novak@gmail.com \
--to=artem122novak@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®