Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs/libfs: don't assume blocksize <= PAGE_SIZE in generic_check_addressable

Since [1], it is possible for filesystems to have blocksize > PAGE_SIZE
of the system.

Remove the assumption and make the check generic for all blocksizes in
generic_check_addressable().

[1] https://lore.kernel.org/linux-xfs/20240822135018.1931258-1-kernel@pankajraghav.com/

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Link: https://lore.kernel.org/20250630104018.213985-1-p.raghav@samsung.com
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Baokun Li <libaokun1@huawei.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Pankaj Raghav and committed by
Christian Brauner
25050181 77eb6443

+7 -3
+7 -3
fs/libfs.c
··· 1584 1584 int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks) 1585 1585 { 1586 1586 u64 last_fs_block = num_blocks - 1; 1587 - u64 last_fs_page = 1588 - last_fs_block >> (PAGE_SHIFT - blocksize_bits); 1587 + u64 last_fs_page, max_bytes; 1588 + 1589 + if (check_shl_overflow(num_blocks, blocksize_bits, &max_bytes)) 1590 + return -EFBIG; 1591 + 1592 + last_fs_page = (max_bytes >> PAGE_SHIFT) - 1; 1589 1593 1590 1594 if (unlikely(num_blocks == 0)) 1591 1595 return 0; 1592 1596 1593 - if ((blocksize_bits < 9) || (blocksize_bits > PAGE_SHIFT)) 1597 + if (blocksize_bits < 9) 1594 1598 return -EINVAL; 1595 1599 1596 1600 if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||