Skip to content

Commit 2f2e09e

Browse files
committed
ext4: add sanity check to ext4_get_group_info()
The group number passed to ext4_get_group_info() should be valid, but let's add an assert to check this before we start creating a pointer based on that group number and dereferencing it. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent b302ef2 commit 2f2e09e

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎fs/ext4/ext4.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,7 @@ struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
23132313
{
23142314
struct ext4_group_info ***grp_info;
23152315
long indexv, indexh;
2316+
BUG_ON(group >= EXT4_SB(sb)->s_groups_count);
23162317
grp_info = EXT4_SB(sb)->s_group_info;
23172318
indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
23182319
indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);

0 commit comments

Comments
 (0)