Skip to content

Commit 227d31b

Browse files
Kemeng Shitytso
authored andcommitted
ext4: avoid potential buffer_head leak in __ext4_new_inode()
If a group is marked EXT4_GROUP_INFO_IBITMAP_CORRUPT after it's inode bitmap buffer_head was successfully verified, then __ext4_new_inode() will get a valid inode_bitmap_bh of a corrupted group from ext4_read_inode_bitmap() in which case inode_bitmap_bh misses a release. Hnadle "IS_ERR(inode_bitmap_bh)" and group corruption separately like how ext4_free_inode() does to avoid buffer_head leak. Fixes: 9008a58 ("ext4: make the bitmap read routines return real error codes") Signed-off-by: Kemeng Shi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 5e5b2a5 commit 227d31b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fs/ext4/ialloc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,12 +1054,13 @@ struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
10541054
brelse(inode_bitmap_bh);
10551055
inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
10561056
/* Skip groups with suspicious inode tables */
1057-
if (((!(sbi->s_mount_state & EXT4_FC_REPLAY))
1058-
&& EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) ||
1059-
IS_ERR(inode_bitmap_bh)) {
1057+
if (IS_ERR(inode_bitmap_bh)) {
10601058
inode_bitmap_bh = NULL;
10611059
goto next_group;
10621060
}
1061+
if (!(sbi->s_mount_state & EXT4_FC_REPLAY) &&
1062+
EXT4_MB_GRP_IBITMAP_CORRUPT(grp))
1063+
goto next_group;
10631064

10641065
repeat_in_this_group:
10651066
ret2 = find_inode_bit(sb, group, inode_bitmap_bh, &ino);

0 commit comments

Comments
 (0)