UPSTREAM: ext4: add strict range checks while freeing blocks
commit a00b482b82fb098956a5bed22bd7873e56f152f1 upstream. Currently ext4_mb_clear_bb() & ext4_group_add_blocks() only checks whether the given block ranges (which is to be freed) belongs to any FS metadata blocks or not, of the block's respective block group. But to detect any FS error early, it is better to add more strict checkings in those functions which checks whether the given blocks belongs to any critical FS metadata or not within system-zone. Suggested-by: Jan Kara <jack@suse.cz> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/ddd9143d064774e32d6364a99667817c6e8bfdc0.1644992610.git.riteshh@linux.ibm.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Bug: 237951970 Change-Id: Ibab39a43f13af206af8c384e7c5590925a089f00 Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
This commit is contained in:

committed by
Matthias Männich

parent
1d4b2a4ad7
commit
0301fe419a
@@ -5361,13 +5361,7 @@ do_more:
|
|||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_range(ext4_block_bitmap(sb, gdp), block, count) ||
|
if (!ext4_inode_block_valid(inode, block, count)) {
|
||||||
in_range(ext4_inode_bitmap(sb, gdp), block, count) ||
|
|
||||||
in_range(block, ext4_inode_table(sb, gdp),
|
|
||||||
sbi->s_itb_per_group) ||
|
|
||||||
in_range(block + count - 1, ext4_inode_table(sb, gdp),
|
|
||||||
sbi->s_itb_per_group)) {
|
|
||||||
|
|
||||||
ext4_error(sb, "Freeing blocks in system zone - "
|
ext4_error(sb, "Freeing blocks in system zone - "
|
||||||
"Block = %llu, count = %lu", block, count);
|
"Block = %llu, count = %lu", block, count);
|
||||||
/* err = 0. ext4_std_error should be a no op */
|
/* err = 0. ext4_std_error should be a no op */
|
||||||
@@ -5437,7 +5431,7 @@ do_more:
|
|||||||
NULL);
|
NULL);
|
||||||
if (err && err != -EOPNOTSUPP)
|
if (err && err != -EOPNOTSUPP)
|
||||||
ext4_msg(sb, KERN_WARNING, "discard request in"
|
ext4_msg(sb, KERN_WARNING, "discard request in"
|
||||||
" group:%d block:%d count:%lu failed"
|
" group:%u block:%d count:%lu failed"
|
||||||
" with %d", block_group, bit, count,
|
" with %d", block_group, bit, count,
|
||||||
err);
|
err);
|
||||||
} else
|
} else
|
||||||
@@ -5650,11 +5644,7 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
|
|||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_range(ext4_block_bitmap(sb, desc), block, count) ||
|
if (!ext4_sb_block_valid(sb, NULL, block, count)) {
|
||||||
in_range(ext4_inode_bitmap(sb, desc), block, count) ||
|
|
||||||
in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) ||
|
|
||||||
in_range(block + count - 1, ext4_inode_table(sb, desc),
|
|
||||||
sbi->s_itb_per_group)) {
|
|
||||||
ext4_error(sb, "Adding blocks in system zones - "
|
ext4_error(sb, "Adding blocks in system zones - "
|
||||||
"Block = %llu, count = %lu",
|
"Block = %llu, count = %lu",
|
||||||
block, count);
|
block, count);
|
||||||
|
Reference in New Issue
Block a user