[PATCH] fs/ntfs3: fix check_log_rec() redo/undo region bounds

From: Vision KC

Date: Thu Nov 19 2026 - 09:46:30 EST


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@xxxxxxxxxxxxxxx
Signed-off-by: Vision KC <vision.kc791@xxxxxxxxx>
---
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