* [PATCH] fs/ntfs3: do not mark frame pages uptodate on read error
@ 2026-07-12 13:34 Weiming Shi
0 siblings, 0 replies; only message in thread
From: Weiming Shi @ 2026-07-12 13:34 UTC (permalink / raw)
To: Konstantin Komarov
Cc: ntfs3, linux-fsdevel, linux-kernel, Xiang Mei, Weiming Shi
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@asu.edu>
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
---
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-12 13:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12 13:34 [PATCH] fs/ntfs3: do not mark frame pages uptodate on read error Weiming Shi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox