dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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