dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/0008-Grow-avoid-overflow-in-compute_backup_blocks.patch

5d5466
From 085df42259cba7863cd6ebe5cd0d8492ac5b869e Mon Sep 17 00:00:00 2001
5d5466
From: NeilBrown <neilb@suse.com>
5d5466
Date: Thu, 6 Dec 2018 10:35:41 +1100
5d5466
Subject: [RHEL7.7 PATCH 08/24] Grow: avoid overflow in compute_backup_blocks()
5d5466
5d5466
With a chunk size of 16Meg and data drive count of 8,
5d5466
this calculate can easily overflow the 'int' type that
5d5466
is used for the multiplications.
5d5466
So force it to use "long" instead.
5d5466
5d5466
Reported-and-tested-by: Ed Spiridonov <edo.rus@gmail.com>
5d5466
Signed-off-by: NeilBrown <neilb@suse.com>
5d5466
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
5d5466
---
5d5466
 Grow.c | 3 ++-
5d5466
 1 file changed, 2 insertions(+), 1 deletion(-)
5d5466
5d5466
diff --git a/Grow.c b/Grow.c
5d5466
index 4436a4d..76f82c0 100644
5d5466
--- a/Grow.c
5d5466
+++ b/Grow.c
5d5466
@@ -1196,7 +1196,8 @@ unsigned long compute_backup_blocks(int nchunk, int ochunk,
5d5466
 	/* Find GCD */
5d5466
 	a = GCD(a, b);
5d5466
 	/* LCM == product / GCD */
5d5466
-	blocks = (ochunk/512) * (nchunk/512) * odata * ndata / a;
5d5466
+	blocks = (unsigned long)(ochunk/512) * (unsigned long)(nchunk/512) *
5d5466
+		odata * ndata / a;
5d5466
 
5d5466
 	return blocks;
5d5466
 }
5d5466
-- 
5d5466
2.7.5
5d5466