dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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