From: Weiming Shi <bestswngs@gmail.com>
To: almaz.alexandrovich@paragon-software.com, ntfs3@lists.linux.dev
Cc: xmei5@asu.edu, Weiming Shi <bestswngs@gmail.com>
Subject: [PATCH] ntfs3: fix out-of-bounds read in ntfs_read_mft()
Date: Thu, 25 Jun 2026 05:07:42 -0700 [thread overview]
Message-ID: <20260625120741.1618516-2-bestswngs@gmail.com> (raw)
ntfs_read_mft() walks the attributes of an MFT record and, for each
FILE_NAME attribute, compares the resident on-disk name with the name
being looked up. The only size check before the compare is
rsize >= SIZEOF_ATTRIBUTE_FILENAME, which covers the fixed header up to
and including name_len, but not the variable-length name that follows it.
name_len comes straight from disk and is not validated against the
resident data_size. A crafted image can set name_len large while keeping
data_size at the header size, so ntfs_cmp_names_cpu() reads name_len
le16 characters past the end of the MFT record buffer:
BUG: KASAN: slab-out-of-bounds in ntfs_cmp_names_cpu (fs/ntfs3/upcase.c:84)
Read of size 2 at addr ffff888031879c00 by task a.out
ntfs_cmp_names_cpu (fs/ntfs3/upcase.c:84)
ntfs_iget5 (fs/ntfs3/inode.c:209)
dir_search_u (fs/ntfs3/dir.c:265)
ntfs_lookup (fs/ntfs3/namei.c:85)
__lookup_slow (fs/namei.c:1915)
lookup_slow (fs/namei.c:1932)
path_lookupat (fs/namei.c:2278)
vfs_statx (fs/stat.c)
vfs_fstatat (fs/stat.c)
__do_sys_newfstatat (fs/stat.c)
Allocated by task:
mi_init (fs/ntfs3/record.c)
ntfs_iget5 (fs/ntfs3/inode.c)
dir_search_u (fs/ntfs3/dir.c)
ntfs_lookup (fs/ntfs3/namei.c)
Check that the name fits in the resident data before using it.
Fixes: 82cae269cfa9 ("fs/ntfs3: Add initialization of super block")
Reported-by: Xiang Mei <xmei5@asu.edu>
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
---
fs/ntfs3/inode.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index c43101cc064d..c41c7231bb87 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -201,6 +201,11 @@ static struct inode *ntfs_read_mft(struct inode *inode,
names += 1;
fname = Add2Ptr(attr, roff);
+
+ /* Make sure the full name fits in the resident data. */
+ if (rsize < fname_full_size(fname))
+ goto out;
+
if (fname->type == FILE_NAME_DOS)
goto next_attr;
--
2.43.0
reply other threads:[~2026-06-25 12:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260625120741.1618516-2-bestswngs@gmail.com \
--to=bestswngs@gmail.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=ntfs3@lists.linux.dev \
--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