1 From 44de022c4382541cebdd6de4465d1f4f465ff1dd Mon Sep 17 00:00:00 2001
2 From: Theodore Ts'o <tytso@mit.edu>
3 Date: Sun, 8 Jul 2018 19:35:02 -0400
4 Subject: ext4: fix false negatives *and* false positives in ext4_check_descriptors()
6 From: Theodore Ts'o <tytso@mit.edu>
8 commit 44de022c4382541cebdd6de4465d1f4f465ff1dd upstream.
10 Ext4_check_descriptors() was getting called before s_gdb_count was
11 initialized. So for file systems w/o the meta_bg feature, allocation
12 bitmaps could overlap the block group descriptors and ext4 wouldn't
15 For file systems with the meta_bg feature enabled, there was a
16 fencepost error which would cause the ext4_check_descriptors() to
17 incorrectly believe that the block allocation bitmap overlaps with the
18 block group descriptor blocks, and it would reject the mount.
20 Fix both of these problems.
22 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
23 Cc: stable@vger.kernel.org
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 fs/ext4/super.c | 5 ++---
28 1 file changed, 2 insertions(+), 3 deletions(-)
32 @@ -2307,7 +2307,7 @@ static int ext4_check_descriptors(struct
33 struct ext4_sb_info *sbi = EXT4_SB(sb);
34 ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
35 ext4_fsblk_t last_block;
36 - ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0) + 1;
37 + ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0);
38 ext4_fsblk_t block_bitmap;
39 ext4_fsblk_t inode_bitmap;
40 ext4_fsblk_t inode_table;
41 @@ -4050,14 +4050,13 @@ static int ext4_fill_super(struct super_
45 + sbi->s_gdb_count = db_count;
46 if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
47 ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
52 - sbi->s_gdb_count = db_count;
54 timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
56 /* Register extent status tree shrinker */