Skip to content

Commit 44de022

Browse files
committed
ext4: fix false negatives *and* false positives in ext4_check_descriptors()
Ext4_check_descriptors() was getting called before s_gdb_count was initialized. So for file systems w/o the meta_bg feature, allocation bitmaps could overlap the block group descriptors and ext4 wouldn't notice. For file systems with the meta_bg feature enabled, there was a fencepost error which would cause the ext4_check_descriptors() to incorrectly believe that the block allocation bitmap overlaps with the block group descriptor blocks, and it would reject the mount. Fix both of these problems. Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent 1e4b044 commit 44de022

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

fs/ext4/super.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,7 +2342,7 @@ static int ext4_check_descriptors(struct super_block *sb,
23422342
struct ext4_sb_info *sbi = EXT4_SB(sb);
23432343
ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
23442344
ext4_fsblk_t last_block;
2345-
ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0) + 1;
2345+
ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0);
23462346
ext4_fsblk_t block_bitmap;
23472347
ext4_fsblk_t inode_bitmap;
23482348
ext4_fsblk_t inode_table;
@@ -4085,14 +4085,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
40854085
goto failed_mount2;
40864086
}
40874087
}
4088+
sbi->s_gdb_count = db_count;
40884089
if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
40894090
ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
40904091
ret = -EFSCORRUPTED;
40914092
goto failed_mount2;
40924093
}
40934094

4094-
sbi->s_gdb_count = db_count;
4095-
40964095
timer_setup(&sbi->s_err_report, print_daily_error_info, 0);
40974096

40984097
/* Register extent status tree shrinker */

0 commit comments

Comments
 (0)