mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<zhanxusheng@xiaomi.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH] fs/ntfs3: bound asize by SIZEOF_NONRESIDENT in check_attr()
Date: Thu, 26 Nov 2026 16:16:13 +0100	[thread overview]
Message-ID: <9aa9b7b5-63d3-4b18-8342-96a639c07fcd@paragon-software.com> (raw)
In-Reply-To: <20260904065437.957677-1-zhanxusheng@xiaomi.com>

On 9/4/26 08:54, Zhan Xusheng wrote:

> check_attr() validates a file record attribute during log replay.  Its
> non-resident branch reads through attr->nres.valid_size, which ends
> SIZEOF_NONRESIDENT bytes into the attribute, but only checks that the
> attribute fits the record, not that it is long enough to hold those
> fields.  check_file_record() admits an attribute starting as late as
> record_size - SIZEOF_RESIDENT, so one placed there with non_res set reads
> up to 40 bytes past mi->mrec, a kmalloc(record_size) buffer.  The later
> "run_off >= asize" rejection is too late: data_size, svcn, evcn and
> valid_size have already been read.  Nothing earlier covers it, mi_read()
> checks only rec->total, and do_action() gets here for the ordinary
> record-modifying operations, so a crafted volume reaches it through
> normal replay.
>
> Reject an attribute that leaves fewer than SIZEOF_NONRESIDENT bytes in the
> record, as mi_enum_attr() already does outside the log path.  A real
> non-resident attribute cannot be smaller than its own header, so nothing
> that mounts today is rejected.
>
> Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal")
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> ---
> Reproduced with ASAN in a userspace replica of the layout and of
> check_attr()'s bounds: an attribute at record_size - SIZEOF_RESIDENT
> gives "READ of size 8 ... located 24 bytes after 1024-byte region",
> and is rejected once the guard is added.
>
> I did not craft a volume, so there is no mount-level reproducer and no
> KASAN splat from a real replay; the reachability above comes from
> reading do_action(), mi_read() and ntfs_fix_post_read().
>
>   fs/ntfs3/fslog.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
> index ed50c1d0c23e..034d72929ac0 100644
> --- a/fs/ntfs3/fslog.c
> +++ b/fs/ntfs3/fslog.c
> @@ -2772,6 +2772,9 @@ static inline bool check_attr(const struct MFT_REC *rec,
>   		break;
>   
>   	case 1:
> +		if (asize < SIZEOF_NONRESIDENT)
> +			return false;
> +
>   		dsize = le64_to_cpu(attr->nres.data_size);
>   		svcn = le64_to_cpu(attr->nres.svcn);
>   		evcn = le64_to_cpu(attr->nres.evcn);
>
> base-commit: a500db7819c50db59e55f1b4fa1c3baa5a2616f3

Hello,

The patch is applied, thanks.

Regards,
Konstantin


      reply	other threads:[~2026-11-26 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  6:54 Zhan Xusheng
2026-11-26 15:16 ` 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=9aa9b7b5-63d3-4b18-8342-96a639c07fcd@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@xiaomi.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®