linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baokun Li <libaokun1@huawei.com>
To: Zhang Yi <yi.zhang@huaweicloud.com>
Cc: <linux-ext4@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <tytso@mit.edu>,
	<adilger.kernel@dilger.ca>, <jack@suse.cz>,
	<wanghaichi0403@gmail.com>, <yi.zhang@huawei.com>,
	<yukuai3@huawei.com>, <yangerkun@huawei.com>
Subject: Re: [PATCH v2 4/4] ext4: ensure i_size is smaller than maxbytes
Date: Tue, 6 May 2025 15:42:29 +0800	[thread overview]
Message-ID: <1fd6eaa8-6e8a-44df-a00d-dfa42f2b81ce@huawei.com> (raw)
In-Reply-To: <20250506012009.3896990-4-yi.zhang@huaweicloud.com>

On 2025/5/6 9:20, Zhang Yi wrote:
> From: Zhang Yi <yi.zhang@huawei.com>
>
> The inode i_size cannot be larger than maxbytes, check it while loading
> inode from the disk.
>
> Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
> Reviewed-by: Jan Kara <jack@suse.cz>
Looks good to me.

Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
>   fs/ext4/inode.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 5691966a19e1..072b61140d12 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4922,7 +4922,8 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
>   		ei->i_file_acl |=
>   			((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32;
>   	inode->i_size = ext4_isize(sb, raw_inode);
> -	if ((size = i_size_read(inode)) < 0) {
> +	size = i_size_read(inode);
> +	if (size < 0 || size > ext4_get_maxbytes(inode)) {
>   		ext4_error_inode(inode, function, line, 0,
>   				 "iget: bad i_size value: %lld", size);
>   		ret = -EFSCORRUPTED;



  reply	other threads:[~2025-05-06  7:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06  1:20 [PATCH v2 1/4] ext4: fix out of bounds punch offset Zhang Yi
2025-05-06  1:20 ` [PATCH v2 2/4] ext4: fix incorrect punch max_end Zhang Yi
2025-05-06  7:39   ` Baokun Li
2025-05-06 11:30   ` Jan Kara
2025-05-06  1:20 ` [PATCH v2 3/4] ext4: factor out ext4_get_maxbytes() Zhang Yi
2025-05-06  7:40   ` Baokun Li
2025-05-06  1:20 ` [PATCH v2 4/4] ext4: ensure i_size is smaller than maxbytes Zhang Yi
2025-05-06  7:42   ` Baokun Li [this message]
2025-05-06  7:37 ` [PATCH v2 1/4] ext4: fix out of bounds punch offset Baokun Li
2025-05-20 14:40 ` Theodore Ts'o

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=1fd6eaa8-6e8a-44df-a00d-dfa42f2b81ce@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=wanghaichi0403@gmail.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yi.zhang@huaweicloud.com \
    --cc=yukuai3@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).