* [PATCH] fs/ntfs3: fix check_log_rec() redo/undo region bounds
@ 2026-11-19 14:45 Vision KC
0 siblings, 0 replies; only message in thread
From: Vision KC @ 2026-11-19 14:45 UTC (permalink / raw)
To: almaz.alexandrovich; +Cc: linux-ntfs3, linux-kernel, stable, Vision KC
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 14:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 14:45 [PATCH] fs/ntfs3: fix check_log_rec() redo/undo region bounds Vision KC
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®