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

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