diff options
author | Baokun Li <libaokun1@huawei.com> | 2024-03-19 19:33:24 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-08-29 17:30:40 +0200 |
commit | 07b373f1e16023c5d0ab52f559ab93520f2b8d8c (patch) | |
tree | b28c78e0104146d71d9357706f13bb7fafa4e114 | |
parent | 5f7b9c3efc9f6d7a847e6b56fac0165d7c1a6d02 (diff) | |
download | linux-07b373f1e16023c5d0ab52f559ab93520f2b8d8c.tar.gz linux-07b373f1e16023c5d0ab52f559ab93520f2b8d8c.tar.bz2 linux-07b373f1e16023c5d0ab52f559ab93520f2b8d8c.zip |
ext4: set the type of max_zeroout to unsigned int to avoid overflow
[ Upstream commit 261341a932d9244cbcd372a3659428c8723e5a49 ]
The max_zeroout is of type int and the s_extent_max_zeroout_kb is of
type uint, and the s_extent_max_zeroout_kb can be freely modified via
the sysfs interface. When the block size is 1024, max_zeroout may
overflow, so declare it as unsigned int to avoid overflow.
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20240319113325.3110393-9-libaokun1@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | fs/ext4/extents.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 5cbe5ae5ad4a..92b540754799 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3404,9 +3404,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle, struct ext4_extent *ex, *abut_ex; ext4_lblk_t ee_block, eof_block; unsigned int ee_len, depth, map_len = map->m_len; - int allocated = 0, max_zeroout = 0; int err = 0; int split_flag = EXT4_EXT_DATA_VALID2; + int allocated = 0; + unsigned int max_zeroout = 0; ext_debug(inode, "logical block %llu, max_blocks %u\n", (unsigned long long)map->m_lblk, map_len); |