lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <t5ijc2nwhq67s5hp6rtpzs3rgdtnunacoj3vnr7pjcwynw7ue3@jlv4abixb2wx>
Date: Mon, 30 Jun 2025 12:25:45 +0200
From: Jan Kara <jack@...e.cz>
To: Pankaj Raghav <p.raghav@...sung.com>
Cc: Alexander Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>, 
	mcgrof@...nel.org, Christian Brauner <brauner@...nel.org>, 
	Baokun Li <libaokun1@...wei.com>, linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org, 
	gost.dev@...sung.com, kernel@...kajraghav.com, Zhang Yi <yi.zhang@...wei.com>
Subject: Re: [PATCH] fs/libfs: don't assume blocksize <= PAGE_SIZE in
 generic_check_addressable

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@pankajraghav.com/
> 
> Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

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@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ