[lustre-devel] [PATCH 18/31] lustre: libcfs: avoid overflow of crypto bandwidth calculation
James Simmons
jsimmons at infradead.org
Mon Jul 30 19:26:10 PDT 2018
From: Gu Zheng <gzheng at ddn.com>
bcount and buf_len are both int, and no force convert in the
calculation code:
tmp = ((bcount * buf_len / jiffies_to_msecs(end - start)) *
1000) / (1024 * 1024);
That may cause overflow in modern fast machine.
Signed-off-by: Gu Zheng <gzheng at ddn.com>
WC-id: https://jira.whamcloud.com/browse/LU-9116
Reviewed-on: https://review.whamcloud.com/25436
Reviewed-by: Andreas Dilger <adilger at whamclud.com>
Reviewed-by: Emoly Liu <emoly at whamcloud.com>
Reviewed-by: James Simmons <uja.ornl at yahoo.com>
Reviewed-by: Li Xi <lixi at ddn.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
drivers/staging/lustre/lnet/libcfs/linux-crypto.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux-crypto.c b/drivers/staging/lustre/lnet/libcfs/linux-crypto.c
index 21ff9bf..cfff54d 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux-crypto.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux-crypto.c
@@ -313,7 +313,8 @@ static void cfs_crypto_performance_test(enum cfs_crypto_hash_alg hash_alg)
int buf_len = max(PAGE_SIZE, 1048576UL);
void *buf;
unsigned long start, end;
- int bcount, err = 0;
+ unsigned long bcount;
+ int err = 0;
struct page *page;
unsigned char hash[CFS_CRYPTO_HASH_DIGESTSIZE_MAX];
unsigned int hash_len = sizeof(hash);
--
1.8.3.1
More information about the lustre-devel
mailing list