From: Giulia Aloia <giulia@bynar.io>
To: almaz.alexandrovich@paragon-software.com
Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
cenzhang@linux.microsoft.com
Subject: [PATCH 1/4] fs/ntfs3: validate dirty page open attribute offsets
Date: Mon, 21 Sep 2026 21:21:36 +0200 [thread overview]
Message-ID: <20260921192157.102738-2-giulia@bynar.io> (raw)
In-Reply-To: <20260921192157.102738-1-giulia@bynar.io>
The dirty-page walk in log_replay() uses dp->target_attr as a byte
offset into the open attribute table without validating it first.
Checking oe->next already dereferences the unchecked pointer.
A malformed dirty-page entry can select the table header, the middle
of an entry, or data beyond the table. The lookup can then read an
invalid entry and follow a bogus attribute pointer.
A crafted table dump containing a fake open attribute entry at
bytes_per_rt(oatbl), within the larger dump buffer, produced the
following on x86-64 before the fix:
KASAN: maybe wild-memory-access in range
[0x4141414141414148-0x414141414141414f]
RIP: 0010:log_replay+0xa698/0xe690
Call Trace:
ntfs_loadlog_and_replay+0x3e0/0x500
ntfs_fill_super+0x1fd3/0x4510
...
Require the offset to be at or beyond the end of the table header,
below the logical table size, and aligned to the table's entry size.
Also require that each entry can hold an OPEN_ATTR_ENRTY; together
these checks keep the whole selected entry within the table. Reject
invalid offsets with -EINVAL, as the redo lookup does. Keep the existing
handling of unallocated entries and NULL attribute pointers.
This lookup uses dirty-page table entries and is separate from the
redo and undo log-record lookups discussed in the linked report.
Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20260901174934.6275-1-cenzhang@linux.microsoft.com/
Assisted-by: Bynario AI
Signed-off-by: Giulia Aloia <giulia@bynar.io>
---
fs/ntfs3/fslog.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
index ed50c1d0c23e..8ac0dbd2f07f 100644
--- a/fs/ntfs3/fslog.c
+++ b/fs/ntfs3/fslog.c
@@ -4987,6 +4987,15 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
if (!dp)
goto do_redo_1;
+ t32 = le32_to_cpu(dp->target_attr);
+ t16 = le16_to_cpu(oatbl->size);
+ if (t16 < sizeof(*oe) || t32 < sizeof(*oatbl) ||
+ t32 >= bytes_per_rt(oatbl) ||
+ (t32 - sizeof(*oatbl)) % t16) {
+ err = -EINVAL;
+ goto out;
+ }
+
oe = Add2Ptr(oatbl, le32_to_cpu(dp->target_attr));
if (oe->next != RESTART_ENTRY_ALLOCATED_LE)
goto next_dirty_page;
--
2.55.0
next prev parent reply other threads:[~2026-09-21 19:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 19:21 [PATCH 0/4] fs/ntfs3: tighten restart-table offset validation Giulia Aloia
2026-09-21 19:21 ` Giulia Aloia [this message]
2026-09-21 19:21 ` [PATCH 2/4] fs/ntfs3: validate restart table offsets in log records Giulia Aloia
2026-09-21 19:21 ` [PATCH 3/4] fs/ntfs3: validate on-disk restart tables before use Giulia Aloia
2026-09-21 19:21 ` [PATCH 4/4] fs/ntfs3: fix out-of-bounds access in alloc_rsttbl_from_idx() Giulia Aloia
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=20260921192157.102738-2-giulia@bynar.io \
--to=giulia@bynar.io \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=cenzhang@linux.microsoft.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®