[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0e379083-ec9b-4b99-b3f4-6f40e7167c61@huawei.com>
Date: Mon, 10 Feb 2025 21:50:57 +0800
From: Baokun Li <libaokun1@...wei.com>
To: Jan Kara <jack@...e.cz>
CC: Ted Tso <tytso@....edu>, <linux-ext4@...r.kernel.org>,
<syzbot+48a99e426f29859818c0@...kaller.appspotmail.com>, "Darrick J. Wong"
<djwong@...nel.org>, Yang Erkun <yangerkun@...wei.com>
Subject: Re: [PATCH] ext4: Verify fast symlink length
On 2025/2/6 17:44, Jan Kara wrote:
> Verify fast symlink length stored in inode->i_size matches the string
> stored in the inode to avoid surprises from corrupted filesystems.
>
> Reported-by: syzbot+48a99e426f29859818c0@...kaller.appspotmail.com
> Tested-by: syzbot+48a99e426f29859818c0@...kaller.appspotmail.com
> Fixes: bae80473f7b0 ("ext4: use inode_set_cached_link()")
> Suggested-by: "Darrick J. Wong" <djwong@...nel.org>
> Signed-off-by: Jan Kara <jack@...e.cz>
> ---
Looks good to me, thanks for the patch!
Reviewed-by: Baokun Li <libaokun1@...wei.com>
> fs/ext4/inode.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 7c54ae5fcbd4..64e280fed911 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -5007,8 +5007,16 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
> inode->i_op = &ext4_encrypted_symlink_inode_operations;
> } else if (ext4_inode_is_fast_symlink(inode)) {
> inode->i_op = &ext4_fast_symlink_inode_operations;
> - nd_terminate_link(ei->i_data, inode->i_size,
> - sizeof(ei->i_data) - 1);
> + if (inode->i_size == 0 ||
> + inode->i_size >= sizeof(ei->i_data) ||
> + strnlen((char *)ei->i_data, inode->i_size + 1) !=
> + inode->i_size) {
> + ext4_error_inode(inode, function, line, 0,
> + "invalid fast symlink length %llu",
> + (unsigned long long)inode->i_size);
> + ret = -EFSCORRUPTED;
> + goto bad_inode;
> + }
> inode_set_cached_link(inode, (char *)ei->i_data,
> inode->i_size);
> } else {
Powered by blists - more mailing lists