Re: [PATCH] fs/libfs: don't assume blocksize <= PAGE_SIZE in generic_check_addressable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon 30-06-25 12:15:09, Pankaj Raghav wrote:
> 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@xxxxxxxxxxxxxxxx/
> 
> Signed-off-by: Pankaj Raghav <p.raghav@xxxxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

One style nit below:

> diff --git a/fs/libfs.c b/fs/libfs.c
> index 4d1862f589e8..81756dc0be6d 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -1584,13 +1584,17 @@ EXPORT_SYMBOL(generic_file_fsync);
>  int generic_check_addressable(unsigned blocksize_bits, u64 num_blocks)
>  {
>  	u64 last_fs_block = num_blocks - 1;
> -	u64 last_fs_page =
> -		last_fs_block >> (PAGE_SHIFT - blocksize_bits);
> +	u64 last_fs_page, max_bytes;
> +
> +	if (check_shl_overflow(num_blocks, blocksize_bits, &max_bytes))
> +		return -EFBIG;
> +
> +	last_fs_page = (max_bytes >> PAGE_SHIFT) - 1;
>  
>  	if (unlikely(num_blocks == 0))
>  		return 0;
>  
> -	if ((blocksize_bits < 9) || (blocksize_bits > PAGE_SHIFT))
> +	if ((blocksize_bits < 9))
            ^ extra parentheses here

>  		return -EINVAL;
>  
>  	if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
> 

								Honza
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux