From: tobgaertner <tob.gaertner@me.com>
To: almaz.alexandrovich@paragon-software.com
Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, security@kernel.org,
Tobias Gaertner <tob.gaertner@me.com>
Subject: [PATCH 1/2] ntfs3: add buffer boundary checks to run_unpack()
Date: Sun, 29 Mar 2026 04:17:02 -0700 [thread overview]
Message-ID: <20260329111704.411449-2-tob.gaertner@me.com> (raw)
In-Reply-To: <20260329111704.411449-1-tob.gaertner@me.com>
From: Tobias Gaertner <tob.gaertner@me.com>
run_unpack() checks `run_buf < run_last` at the top of the while loop
but then reads size_size and offset_size bytes via run_unpack_s64()
without verifying they fit within the remaining buffer. A crafted NTFS
image with truncated run data in an MFT attribute triggers an OOB heap
read of up to 15 bytes when the filesystem is mounted.
Add boundary checks before each run_unpack_s64() call to ensure the
declared field size does not exceed the remaining buffer.
Found by fuzzing with a source-patched harness (LibAFL + QEMU).
Fixes: 82cae269cfa95 ("fs/ntfs3: Add initialization of super block")
Cc: stable@vger.kernel.org
Signed-off-by: Tobias Gaertner <tob.gaertner@me.com>
---
fs/ntfs3/run.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
index 395b20492..c3c6917fa 100644
--- a/fs/ntfs3/run.c
+++ b/fs/ntfs3/run.c
@@ -970,6 +970,9 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
if (size_size > sizeof(len))
return -EINVAL;
+ if (run_buf + size_size > run_last)
+ return -EINVAL;
+
len = run_unpack_s64(run_buf, size_size, 0);
/* Skip size_size. */
run_buf += size_size;
@@ -982,6 +985,9 @@ int run_unpack(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
else if (offset_size <= sizeof(s64)) {
s64 dlcn;
+ if (run_buf + offset_size > run_last)
+ return -EINVAL;
+
/* Initial value of dlcn is -1 or 0. */
dlcn = (run_buf[offset_size - 1] & 0x80) ? (s64)-1 : 0;
dlcn = run_unpack_s64(run_buf, offset_size, dlcn);
--
2.43.0
next prev parent reply other threads:[~2026-03-29 11:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-29 11:17 [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() tobgaertner
2026-03-29 11:17 ` tobgaertner [this message]
2026-03-29 11:17 ` [PATCH 2/2] ntfs3: fix integer overflow in run_unpack() volume boundary check tobgaertner
2026-04-07 17:19 ` [PATCH 0/2] ntfs3: fix OOB read and integer overflow in run_unpack() Konstantin Komarov
2026-04-15 4:19 ` Tobias Gaertner
2026-04-15 7:00 ` Willy Tarreau
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=20260329111704.411449-2-tob.gaertner@me.com \
--to=tob.gaertner@me.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=security@kernel.org \
--cc=stable@vger.kernel.org \
/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