Skip to content

Commit fdff73f

Browse files
committed
ext4: Initialize the new group descriptor when resizing the filesystem
Make sure all of the fields of the group descriptor are properly initialized. Previously, we allowed bg_flags field to be contain random garbage, which could trigger non-deterministic behavior, including a kernel OOPS. http://bugzilla.kernel.org/show_bug.cgi?id=12433 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: stable@kernel.org
1 parent e7f0796 commit fdff73f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎fs/ext4/resize.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,13 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
861861
gdp = (struct ext4_group_desc *)((char *)primary->b_data +
862862
gdb_off * EXT4_DESC_SIZE(sb));
863863

864+
memset(gdp, 0, EXT4_DESC_SIZE(sb));
864865
ext4_block_bitmap_set(sb, gdp, input->block_bitmap); /* LV FIXME */
865866
ext4_inode_bitmap_set(sb, gdp, input->inode_bitmap); /* LV FIXME */
866867
ext4_inode_table_set(sb, gdp, input->inode_table); /* LV FIXME */
867868
ext4_free_blks_set(sb, gdp, input->free_blocks_count);
868869
ext4_free_inodes_set(sb, gdp, EXT4_INODES_PER_GROUP(sb));
869-
gdp->bg_flags |= cpu_to_le16(EXT4_BG_INODE_ZEROED);
870+
gdp->bg_flags = cpu_to_le16(EXT4_BG_INODE_ZEROED);
870871
gdp->bg_checksum = ext4_group_desc_csum(sbi, input->group, gdp);
871872

872873
/*

0 commit comments

Comments
 (0)