mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: "Xiang Mei (Microsoft)" <xmei5@asu.edu>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<AutonomousCodeSecurity@microsoft.com>,
	<tgopinath@linux.microsoft.com>, <kys@microsoft.com>
Subject: Re: [PATCH] fs/ntfs3: check INDEX_ROOT resident size before use in ntfs_read_mft()
Date: Mon, 21 Sep 2026 12:55:22 +0200	[thread overview]
Message-ID: <58801f27-bf38-474e-be74-c74d3473d446@paragon-software.com> (raw)
In-Reply-To: <20260707015440.3420673-1-xmei5@asu.edu>

On 7/7/26 03:54, Xiang Mei (Microsoft) wrote:

> When ntfs_read_mft() parses an ATTR_ROOT attribute it computes
>
> 	root = Add2Ptr(attr, roff);
>
> using the on-disk resident data offset (roff = attr->res.data_off) and
> then dereferences root->type and root->rule, and later passes root on to
> indx_init(). Unlike the ATTR_STD and ATTR_NAME cases, which validate that
> the resident data is large enough (asize >= sizeof(struct X) + roff and
> rsize >= sizeof(struct X)) before accessing it, the ATTR_ROOT case has no
> such check.
>
> mi_enum_attr() only guarantees data_off + data_size <= attribute size, so
> a crafted image can set data_off such that root lands at (or past) the end
> of the MFT record's slab allocation while still passing that check (e.g.
> data_size == 0). The subsequent read of root->type is then a
> slab-out-of-bounds read, reported by KASAN when mounting the image:
>
>    BUG: KASAN: slab-out-of-bounds in ntfs_iget5 (fs/ntfs3/inode.c:283)
>    Read of size 4 at addr ffff88800c06a400 by task exploit/142
>    Call Trace:
>     ...  [KASAN report internals]
>     ntfs_iget5 (fs/ntfs3/inode.c:283 fs/ntfs3/inode.c:542)
>     ntfs_fill_super (fs/ntfs3/super.c:1690)
>     get_tree_bdev_flags (fs/super.c:1634)
>     vfs_get_tree (fs/super.c:1694)
>     fc_mount (fs/namespace.c:1198)
>     path_mount (fs/namespace.c:3765 ...)
>     __x64_sys_mount (fs/namespace.c:4174 ...)
>     do_syscall_64 (arch/x86/entry/syscall_64.c:63)
>     entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
>    The buggy address is located 0 bytes to the right of
>     allocated 1024-byte region [ffff88800c06a000, ffff88800c06a400)
>     which belongs to the cache kmalloc-1k of size 1024
>
> Validate the resident data size in the ATTR_ROOT case the same way the
> neighbouring cases do, so that a truncated or mis-offset INDEX_ROOT is
> rejected before root is dereferenced.
>
> Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
> Reported-by: AutonomousCodeSecurity@microsoft.com
> Signed-off-by: Xiang Mei (Microsoft) <xmei5@asu.edu>
> ---
>   fs/ntfs3/inode.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index c43101cc064d..efb6a855c5ad 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -271,7 +271,9 @@ static struct inode *ntfs_read_mft(struct inode *inode,
>   		break;
>   
>   	case ATTR_ROOT:
> -		if (attr->non_res)
> +		if (attr->non_res ||
> +		    asize < sizeof(struct INDEX_ROOT) + roff ||
> +		    rsize < sizeof(struct INDEX_ROOT))
>   			goto out;
>   
>   		root = Add2Ptr(attr, roff);

Hello,

Sorry for the delay.
Your patch was applied, thank you.

Regards,
Konstantin


      reply	other threads:[~2026-09-21 10:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07  1:54 Xiang Mei (Microsoft)
2026-09-21 10:55 ` 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=58801f27-bf38-474e-be74-c74d3473d446@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=AutonomousCodeSecurity@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=tgopinath@linux.microsoft.com \
    --cc=xmei5@asu.edu \
    /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®