]> git.dujemihanovic.xyz Git - linux.git/commitdiff
ext4: set the type of max_zeroout to unsigned int to avoid overflow
authorBaokun Li <libaokun1@huawei.com>
Tue, 19 Mar 2024 11:33:24 +0000 (19:33 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 3 May 2024 03:48:31 +0000 (23:48 -0400)
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>
fs/ext4/extents.c

index e57054bdc5fd81e796298fa90a7d47d9ddd2b248..e067f2dd0335cd28b735da28091d04535c1dccd6 100644 (file)
@@ -3402,9 +3402,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);