mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Xue Boyang <fuchen.dust@gmail.com>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH ntfs] fs/ntfs3: fix out-of-bounds write in UpdateFileName replay
Date: Thu, 26 Nov 2026 16:35:30 +0100	[thread overview]
Message-ID: <26e97827-8544-459a-94c0-cb53f76bd0fd@paragon-software.com> (raw)
In-Reply-To: <20260929090452.224281-1-fuchen.dust@gmail.com>

On 9/29/26 11:04, Xue Boyang wrote:

> During $LogFile replay, do_action()'s UpdateFileNameRoot and
> UpdateFileNameAllocation cases write sizeof(NTFS_DUP_INFO) = 0x38 bytes
> into the ATTR_FILE_NAME structure that follows the target index entry:
>
>          e = Add2Ptr(attr, le16_to_cpu(lrh->attr_off));
>          fname = (struct ATTR_FILE_NAME *)(e + 1);
>          memmove(&fname->dup, data, sizeof(fname->dup));
>
> The gates that run before the write (check_if_index_root and
> check_if_root_index) only validate that the record and entry offsets
> land on boundaries.  Neither checks that the entry's key_size is large
> enough to hold a struct ATTR_FILE_NAME, whose minimum size is
> SIZEOF_ATTRIBUTE_FILENAME (0x44).  de_get_fname() applies exactly this
> check at every other call site; the replay path omits it.
>
> With a crafted $LogFile whose UpdateFileNameRoot record points at a
> 16-byte entry with key_size = 0 placed at the end of a crafted $I30
> INDEX_ROOT, the write lands past the end of the kmalloc(record_size)
> MFT record allocation:
>
>    BUG: KASAN: slab-out-of-bounds in do_action+0x14af/0x1d35
>    Write of size 56 at addr ffff888004046be8 by task mount/71
>     ...
>     __asan_memmove+0x3c/0x60
>     do_action+0x14af/0x1d35
>     log_replay (fs/ntfs3/fslog.c)
>     ntfs_loadlog_and_replay+0x2cb/0x300
>     ntfs_fill_super+0x1375/0x22d0
>     ...
>
> The write content is fully attacker-controlled (redo data from the log
> record) and the trigger is deterministic on every rw mount, no race.
>
> Reject the operation when key_size is below SIZEOF_ATTRIBUTE_FILENAME
> in both cases, matching de_get_fname().
>
> Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS3 filesystem")
> Assisted-by: GLM:zhipu-coding-plan/glm-5.3
> Signed-off-by: Xue Boyang <fuchen.dust@gmail.com>
> ---
>   fs/ntfs3/fslog.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
> index 498f63da2b96..ba61767cab3f 100644
> --- a/fs/ntfs3/fslog.c
> +++ b/fs/ntfs3/fslog.c
> @@ -3557,8 +3557,10 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
>                  }
>
>                  e = Add2Ptr(attr, le16_to_cpu(lrh->attr_off));
> +               if (le16_to_cpu(e->key_size) < SIZEOF_ATTRIBUTE_FILENAME)
> +                       goto dirty_vol;
>                  fname = (struct ATTR_FILE_NAME *)(e + 1);
> -               memmove(&fname->dup, data, sizeof(fname->dup)); //
> +               memmove(&fname->dup, data, sizeof(fname->dup));
>                  mi->dirty = true;
>                  break;
>
> @@ -3742,6 +3744,8 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
>                          goto dirty_vol;
>                  }
>
> +               if (le16_to_cpu(e->key_size) < SIZEOF_ATTRIBUTE_FILENAME)
> +                       goto dirty_vol;
>                  fname = (struct ATTR_FILE_NAME *)(e + 1);
>                  memmove(&fname->dup, data, sizeof(fname->dup));
>
> --
> 2.53.0

Hello,

Thanks for the patch. Yunpeng Tian already addressed the same issue in
commit be477eb99013 (“fs/ntfs3: require a FILE_NAME key before the UpdateFileName* replay copy”).

Regards,
Konstantin


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29  9:04 Xue Boyang
2026-11-26 15:35 ` 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=26e97827-8544-459a-94c0-cb53f76bd0fd@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=fuchen.dust@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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®