Skip to content

Commit dd69aba

Browse files
tytsogregkh
authored andcommitted
ext4: fix false negatives *and* false positives in ext4_check_descriptors()
commit 44de022 upstream. 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] Signed-off-by: Benjamin Gilbert <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 09901e5 commit dd69aba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/ext4/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ static int ext4_check_descriptors(struct super_block *sb,
23012301
struct ext4_sb_info *sbi = EXT4_SB(sb);
23022302
ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
23032303
ext4_fsblk_t last_block;
2304-
ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0) + 1;
2304+
ext4_fsblk_t last_bg_block = sb_block + ext4_bg_num_gdb(sb, 0);
23052305
ext4_fsblk_t block_bitmap;
23062306
ext4_fsblk_t inode_bitmap;
23072307
ext4_fsblk_t inode_table;
@@ -4038,13 +4038,13 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
40384038
goto failed_mount2;
40394039
}
40404040
}
4041+
sbi->s_gdb_count = db_count;
40414042
if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) {
40424043
ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
40434044
ret = -EFSCORRUPTED;
40444045
goto failed_mount2;
40454046
}
40464047

4047-
sbi->s_gdb_count = db_count;
40484048
get_random_bytes(&sbi->s_next_generation, sizeof(u32));
40494049
spin_lock_init(&sbi->s_next_gen_lock);
40504050

0 commit comments

Comments
 (0)