]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ntfs: Do not overwrite uptodate pages
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 18 Jul 2025 19:53:58 +0000 (20:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Jan 2026 09:16:52 +0000 (10:16 +0100)
commit791bc3890d6fa56c9de803d601402919d189687f
tree21d3369c4d03e678290fc9fcef4e14334f73f636
parent7c87afd13484f1399cd7a7ac4d9c1e611d0f222f
ntfs: Do not overwrite uptodate pages

commit 68f6bd128e75a032432eda9d16676ed2969a1096 upstream.

When reading a compressed file, we may read several pages in addition to
the one requested.  The current code will overwrite pages in the page
cache with the data from disc which can definitely result in changes
that have been made being lost.

For example if we have four consecutie pages ABCD in the file compressed
into a single extent, on first access, we'll bring in ABCD.  Then we
write to page B.  Memory pressure results in the eviction of ACD.
When we attempt to write to page C, we will overwrite the data in page
B with the data currently on disk.

I haven't investigated the decompression code to check whether it's
OK to overwrite a clean page or whether it might be possible to see
corrupt data.  Out of an abundance of caution, decline to overwrite
uptodate pages, not just dirty pages.

Fixes: 4342306f0f0d (fs/ntfs3: Add file operations and implementation)
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ntfs3/frecord.c