mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vision KC <vision.kc791@gmail.com>
To: almaz.alexandrovich@paragon-software.com
Cc: linux-ntfs3@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Vision KC <vision.kc791@gmail.com>
Subject: [PATCH] fs/ntfs3: fix check_log_rec() redo/undo region bounds
Date: Thu, 19 Nov 2026 20:30:21 +0545	[thread overview]
Message-ID: <20261119144521.86377-1-vision.kc791@gmail.com> (raw)

check_log_rec() validates that redo_off and undo_off are 8-byte
aligned and that bytes >= lrh_length(lr), but lrh_length() only
covers the LOG_REC_HDR header plus the embedded page_lcns array.
It does not check that redo_off + redo_len or undo_off + undo_len
fall within the bounds of the log record buffer.

A crafted $LogFile can set client_data_len to a small value (e.g.
40), redo_off to that same value, and redo_len to 0xFFF0. The
kernel allocates a 40-byte buffer via kmalloc() in find_log_rec(),
computes a pointer one byte past the end of that buffer, and
iterates 4,095 times reading 16 bytes of adjacent kernel heap per
iteration (65,520 bytes of OOB reads total) in the
DeleteDirtyClusters handler of log_replay().

KASAN report:
  BUG: KASAN: slab-out-of-bounds in log_replay+0xb0b3/0xe8c0
  Read of size 8 at addr ffff888009117228 by task mount/85
  The buggy address is located 0 bytes to the right of
  allocated 40-byte region [ffff888009117200, ffff888009117228)

Fix by adding bounds checks for the redo and undo data regions in
check_log_rec(): verify that redo_off + redo_len and undo_off +
undo_len each fit within the log record buffer.

Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal")
Cc: stable@vger.kernel.org
Signed-off-by: Vision KC <vision.kc791@gmail.com>
---
 fs/ntfs3/fslog.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/fs/ntfs3/fslog.c b/fs/ntfs3/fslog.c
index bb8d40bb5..cd251ee9b 100644
--- a/fs/ntfs3/fslog.c
+++ b/fs/ntfs3/fslog.c
@@ -733,6 +733,20 @@ static bool check_log_rec(const struct LOG_REC_HDR *lr, u32 bytes, u32 tr,
 	if (bytes < lrh_length(lr))
 		return false;
 
+	if (lr->redo_len) {
+		u32 rend = le16_to_cpu(lr->redo_off) +
+			   le16_to_cpu(lr->redo_len);
+		if (rend > bytes)
+			return false;
+	}
+
+	if (lr->undo_len) {
+		u32 uend = le16_to_cpu(lr->undo_off) +
+			   le16_to_cpu(lr->undo_len);
+		if (uend > bytes)
+			return false;
+	}
+
 	return true;
 }
 
-- 
2.56.0


                 reply	other threads:[~2026-11-19 14:46 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=20261119144521.86377-1-vision.kc791@gmail.com \
    --to=vision.kc791@gmail.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntfs3@vger.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

all inboxes | Powered by JetHome®