mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Peng Zhang <zhangpeng362@huawei.com>,
	<kari.argillander@gmail.com>, <paskripkin@gmail.com>,
	<jack@suse.cz>, <yi.zhang@huawei.com>, <hch@lst.de>,
	<akpm@linux-foundation.org>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<sunnanyong@huawei.com>, <wangkefeng.wang@huawei.com>,
	<syzbot+d882d57193079e379309@syzkaller.appspotmail.com>
Subject: Re: [PATCH] fs/ntfs3: Fix OOB read in indx_insert_into_buffer
Date: Mon, 26 Dec 2022 18:03:27 +0400	[thread overview]
Message-ID: <827ff7b2-8246-378b-e389-150d22205e9b@paragon-software.com> (raw)
In-Reply-To: <20221207094610.998485-1-zhangpeng362@huawei.com>


On 07.12.2022 13:46, Peng Zhang wrote:
> From: ZhangPeng <zhangpeng362@huawei.com>
>
> Syzbot reported a OOB read bug:
>
> BUG: KASAN: slab-out-of-bounds in indx_insert_into_buffer+0xaa3/0x13b0
> fs/ntfs3/index.c:1755
> Read of size 17168 at addr ffff8880255e06c0 by task syz-executor308/3630
>
> Call Trace:
>   <TASK>
>   memmove+0x25/0x60 mm/kasan/shadow.c:54
>   indx_insert_into_buffer+0xaa3/0x13b0 fs/ntfs3/index.c:1755
>   indx_insert_entry+0x446/0x6b0 fs/ntfs3/index.c:1863
>   ntfs_create_inode+0x1d3f/0x35c0 fs/ntfs3/inode.c:1548
>   ntfs_create+0x3e/0x60 fs/ntfs3/namei.c:100
>   lookup_open fs/namei.c:3413 [inline]
>
> If the member struct INDEX_BUFFER *index of struct indx_node is
> incorrect, that is, the value of __le32 used is greater than the value
> of __le32 total in struct INDEX_HDR. Therefore, OOB read occurs when
> memmove is called in indx_insert_into_buffer().
> Fix this by adding a check in hdr_find_e().
>
> Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
> Reported-by: syzbot+d882d57193079e379309@syzkaller.appspotmail.com
> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
> ---
>   fs/ntfs3/index.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
> index 440328147e7e..28af0a5afbf2 100644
> --- a/fs/ntfs3/index.c
> +++ b/fs/ntfs3/index.c
> @@ -679,9 +679,13 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
>   	u32 e_size, e_key_len;
>   	u32 end = le32_to_cpu(hdr->used);
>   	u32 off = le32_to_cpu(hdr->de_off);
> +	u32 total = le32_to_cpu(hdr->total);
>   	u16 offs[128];
>   
>   fill_table:
> +	if (end > total)
> +		return NULL;
> +
>   	if (off + sizeof(struct NTFS_DE) > end)
>   		return NULL;
>   
Applied, thanks for the patch!

      reply	other threads:[~2022-12-26 14:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07  9:46 Peng Zhang
2022-12-26 14:03 ` Konstantin Komarov [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=827ff7b2-8246-378b-e389-150d22205e9b@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=kari.argillander@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=paskripkin@gmail.com \
    --cc=sunnanyong@huawei.com \
    --cc=syzbot+d882d57193079e379309@syzkaller.appspotmail.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=zhangpeng362@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

all inboxes | Powered by JetHome®