public inbox for ntfs3@lists.linux.dev
 help / color / mirror / Atom feed
From: Zeng Heng <zengheng4@huawei.com>
To: <almaz.alexandrovich@paragon-software.com>
Cc: <ntfs3@lists.linux.dev>, <liwei391@huawei.com>,
	<linux-kernel@vger.kernel.org>, <syzkaller-bugs@googlegroups.com>
Subject: Re: [PATCH] ntfs: fix panic about slab-out-of-bounds caused by ntfs_listxattr()
Date: Tue, 10 Jan 2023 19:04:40 +0800	[thread overview]
Message-ID: <ca708dc7-cd97-2b64-37e9-1abf84df28c9@huawei.com> (raw)
In-Reply-To: <20221207162807.227498-1-zengheng4@huawei.com>


On 2022/12/8 0:28, Zeng Heng wrote:
> Here is a BUG report from syzbot:
>
> BUG: KASAN: slab-out-of-bounds in ntfs_list_ea fs/ntfs3/xattr.c:191 [inline]
> BUG: KASAN: slab-out-of-bounds in ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710
> Read of size 1 at addr ffff888021acaf3d by task syz-executor128/3632
>
> Call Trace:
>   ntfs_list_ea fs/ntfs3/xattr.c:191 [inline]
>   ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710
>   vfs_listxattr fs/xattr.c:457 [inline]
>   listxattr+0x293/0x2d0 fs/xattr.c:804
>
> Fix the logic of ea_all iteration. When the ea->name_len is 0,
> return immediately, or Add2Ptr() would visit invalid memory
> in the next loop.
>
> Fixes: be71b5cba2e6 ("fs/ntfs3: Add attrib operations")
> Reported-by: syzbot+9fcea5ef6dc4dc72d334@syzkaller.appspotmail.com
> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
> ---
>   fs/ntfs3/xattr.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 7de8718c68a9..911e110b8d6e 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -178,6 +178,9 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,
>   	for (ret = 0, off = 0; off < size; off += unpacked_ea_size(ea)) {
>   		ea = Add2Ptr(ea_all, off);
>   
> +		if (!ea->name_len)
> +			break;
> +
>   		if (buffer) {
>   			if (ret + ea->name_len + 1 > bytes_per_buffer) {
>   				err = -ERANGE;

Is there any comment about this patch?

Thanks for advance.


Zeng Heng



      reply	other threads:[~2023-01-10 11:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 16:28 [PATCH] ntfs: fix panic about slab-out-of-bounds caused by ntfs_listxattr() Zeng Heng
2023-01-10 11:04 ` Zeng Heng [this message]

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=ca708dc7-cd97-2b64-37e9-1abf84df28c9@huawei.com \
    --to=zengheng4@huawei.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liwei391@huawei.com \
    --cc=ntfs3@lists.linux.dev \
    --cc=syzkaller-bugs@googlegroups.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