]> git.itanic.dy.fi Git - linux-stable/commit
ext4: add two helper functions extent_logical_end() and pa_logical_end()
authorBaokun Li <libaokun1@huawei.com>
Sat, 28 Oct 2023 06:47:47 +0000 (14:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 8 Nov 2023 16:26:43 +0000 (17:26 +0100)
commit7a992726f727919599d2a00906018586a9d34b54
treed32e029fc48ce212ced37a121d7a62f7b9e89a61
parent9e78e7709f7d4b4da5c82a98d31ce5f74cc6a126
ext4: add two helper functions extent_logical_end() and pa_logical_end()

commit 43bbddc067883d94de7a43d5756a295439fbe37d upstream.

When we use lstart + len to calculate the end of free extent or prealloc
space, it may exceed the maximum value of 4294967295(0xffffffff) supported
by ext4_lblk_t and cause overflow, which may lead to various problems.

Therefore, we add two helper functions, extent_logical_end() and
pa_logical_end(), to limit the type of end to loff_t, and also convert
lstart to loff_t for calculation to avoid overflow.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Link: https://lore.kernel.org/r/20230724121059.11834-2-libaokun1@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/mballoc.c
fs/ext4/mballoc.h