Skip to content

Commit 463808f

Browse files
committed
ext4: remove a BUG_ON in ext4_mb_release_group_pa()
If a malicious fuzzer overwrites the ext4 superblock while it is mounted such that the s_first_data_block is set to a very large number, the calculation of the block group can underflow, and trigger a BUG_ON check. Change this to be an ext4_warning so that we don't crash the kernel. Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Reported-by: [email protected] Link: https://syzkaller.appspot.com/bug?id=69b28112e098b070f639efb356393af3ffec4220 Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 5354b2a commit 463808f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/ext4/mballoc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5047,7 +5047,11 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
50475047
trace_ext4_mb_release_group_pa(sb, pa);
50485048
BUG_ON(pa->pa_deleted == 0);
50495049
ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
5050-
BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
5050+
if (unlikely(group != e4b->bd_group && pa->pa_len != 0)) {
5051+
ext4_warning(sb, "bad group: expected %u, group %u, pa_start %llu",
5052+
e4b->bd_group, group, pa->pa_pstart);
5053+
return 0;
5054+
}
50515055
mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
50525056
atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
50535057
trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);

0 commit comments

Comments
 (0)