Commit 31562b95 authored by Jan Kara's avatar Jan Kara Committed by Theodore Ts'o

ext4: make sanity check in mballoc more strict

The sanity check in mb_find_extent() only checked that returned extent
does not extend past blocksize * 8, however it should not extend past
EXT4_CLUSTERS_PER_GROUP(sb). This can happen when clusters_per_group <
blocksize * 8 and the tail of the bitmap is not properly filled by 1s
which happened e.g. when ancient kernels have grown the filesystem.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
parent fb203751
...@@ -1539,7 +1539,7 @@ static int mb_find_extent(struct ext4_buddy *e4b, int block, ...@@ -1539,7 +1539,7 @@ static int mb_find_extent(struct ext4_buddy *e4b, int block,
ex->fe_len += 1 << order; ex->fe_len += 1 << order;
} }
if (ex->fe_start + ex->fe_len > (1 << (e4b->bd_blkbits + 3))) { if (ex->fe_start + ex->fe_len > EXT4_CLUSTERS_PER_GROUP(e4b->bd_sb)) {
/* Should never happen! (but apparently sometimes does?!?) */ /* Should never happen! (but apparently sometimes does?!?) */
WARN_ON(1); WARN_ON(1);
ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent " ext4_error(e4b->bd_sb, "corruption or bug in mb_find_extent "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment