[PATCH] fs/ntfs3: do not mark frame pages uptodate on read error
From: Weiming Shi
Date: Sun Jul 12 2026 - 09:34:58 EST
ni_read_frame() ends with a loop that marks every page of a compressed
frame uptodate regardless of whether the read succeeded:
out:
for (i = 0; i < pages_per_frame; i++) {
pg = pages[i];
SetPageUptodate(pg);
}
Non-critical frame pages come from __filemap_get_folio(FGP_CREAT) and are
not zeroed. On an error path that reaches out: before frame_mem is
written, these pages keep uninitialized page-allocator contents but are
still marked uptodate. A later read() is then served from the page cache
and returns that stale kernel memory to user space.
For an unprivileged user mounting a crafted NTFS image this is a
repeatable kernel memory disclosure.
Mark the pages uptodate only on success; on error leave them !uptodate so
the read path re-reads them or reports the error.
Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation")
Reported-by: Xiang Mei <xmei5@xxxxxxx>
Signed-off-by: Weiming Shi <bestswngs@xxxxxxxxx>
---
fs/ntfs3/frecord.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 2d2644d80017..862baafb80e3 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -2467,7 +2467,8 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,
out:
for (i = 0; i < pages_per_frame; i++) {
pg = pages[i];
- SetPageUptodate(pg);
+ if (!err)
+ SetPageUptodate(pg);
}
return err;
--
2.43.0