linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baokun Li <libaokun1@huawei.com>
To: Pankaj Raghav <p.raghav@samsung.com>
Cc: Christian Brauner <brauner@kernel.org>, <mcgrof@kernel.org>,
	Jan Kara <jack@suse.cz>, Alexander Viro <viro@zeniv.linux.org.uk>,
	<linux-kernel@vger.kernel.org>, <kernel@pankajraghav.com>,
	Zhang Yi <yi.zhang@huawei.com>, <linux-fsdevel@vger.kernel.org>,
	<gost.dev@samsung.com>, Yang Erkun <yangerkun@huawei.com>
Subject: Re: [PATCH v2] fs/libfs: don't assume blocksize <= PAGE_SIZE in generic_check_addressable
Date: Mon, 30 Jun 2025 19:38:25 +0800	[thread overview]
Message-ID: <8ffabe04-b12c-4d1c-8e09-f1db8c72e6d5@huawei.com> (raw)
In-Reply-To: <20250630104018.213985-1-p.raghav@samsung.com>

On 2025/6/30 18:40, 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/
>
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>

Looks good. Feel free to add:

Reviewed-by: Baokun Li <libaokun1@huawei.com>

> ---
> Changes since v1:
> - Removed the unnecessary parantheses.
> - Added RVB from Jan Kara (Thanks).
>
>   fs/libfs.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 4d1862f589e8..f99ecc300647 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)
>   		return -EINVAL;
>   
>   	if ((last_fs_block > (sector_t)(~0ULL) >> (blocksize_bits - 9)) ||
>
> base-commit: b39f7d75dc41b5f5d028192cd5d66cff71179f35



  reply	other threads:[~2025-06-30 11:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 10:40 [PATCH v2] fs/libfs: don't assume blocksize <= PAGE_SIZE in generic_check_addressable Pankaj Raghav
2025-06-30 11:38 ` Baokun Li [this message]
2025-06-30 11:57 ` Zhang Yi
2025-07-01 11:57 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ffabe04-b12c-4d1c-8e09-f1db8c72e6d5@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=brauner@kernel.org \
    --cc=gost.dev@samsung.com \
    --cc=jack@suse.cz \
    --cc=kernel@pankajraghav.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=p.raghav@samsung.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).