Blame SOURCES/e2fsprogs-1.42.9-14-mke2fs-Avoid-crashes-infinite-loops-for-absurdly-lar.patch

252946
From f7da56758e5d15416339d640f79d6eee875d22a9 Mon Sep 17 00:00:00 2001
252946
From: Jan Kara <jack@suse.cz>
252946
Date: Tue, 25 Oct 2016 14:08:59 -0400
252946
Subject: [PATCH 09/16] mke2fs: Avoid crashes / infinite loops for absurdly
252946
 large devices
252946
252946
commit 101ef2e93c253ae62320628e8958067d2d2a4e2a
252946
252946
When a device reports absurdly high size, some arithmetics in mke2fs can
252946
overflow (e.g. number of block descriptors) and we end in an infinite
252946
loop. Fix that by checking and refusing insanely large devices.
252946
252946
Signed-off-by: Jan Kara <jack@suse.cz>
252946
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
252946
---
252946
 misc/mke2fs.c | 12 ++++++++++++
252946
 1 file changed, 12 insertions(+)
252946
252946
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
252946
index 2787a127..7cea0330 100644
252946
--- a/misc/mke2fs.c
252946
+++ b/misc/mke2fs.c
252946
@@ -1858,6 +1858,18 @@ profile_error:
252946
 			EXT2_BLOCK_SIZE(&fs_param));
252946
 		exit(1);
252946
 	}
252946
+	/*
252946
+	 * Guard against group descriptor count overflowing... Mostly to avoid
252946
+	 * strange results for absurdly large devices.
252946
+	 */
252946
+	if (fs_blocks_count > ((1ULL << (fs_param.s_log_block_size + 3 + 32)) - 1)) {
252946
+		fprintf(stderr, _("%s: Size of device (0x%llx blocks) %s "
252946
+				  "too big to create\n\t"
252946
+				  "a filesystem using a blocksize of %d.\n"),
252946
+			program_name, fs_blocks_count, device_name,
252946
+			EXT2_BLOCK_SIZE(&fs_param));
252946
+		exit(1);
252946
+	}
252946
 
252946
 	ext2fs_blocks_count_set(&fs_param, fs_blocks_count);
252946
 
252946
-- 
252946
2.20.1
252946