fs/ntfs3: fix silent corruption reading compressed files
cover fs/ntfs3: fix silent corruption reading compressed files
Reading WOF (LZX/XPRESS) compressed files on ntfs3 can silently return wrong data: zeroes or garbage, no error from read(), nothing in dmesg. The bad pages stay in the page cache until it is dropped.
It needs two bugs together:
1. ntfs_read_write_run() maps page 0 of the block device folio it gets from read_mapping_folio(), which is wrong for large folios. Those appear when userspace has read the block device (e.g. ntfs-3g tools), so the compressed input comes from the wrong 4 KiB page and the decompressor fails. The same helper is used for compressed writes.
2. ni_read_frame() marks the frame's pages uptodate even when it fails, so the failure is turned into silently wrong data.
Found while copying a Windows drive whose files had been compacted with "compact /exe:lzx". The data on disk is intact: decoding the WofCompressedData streams independently with wimlib gives the right contents, matching uncompressed copies of the same files.
Tested on 7.3 against 16,716 WOF-compressed files (LZX, 32K frames):
the reproducer in patch 1 fails for 1,051 files without the series and for none with it. With only patch 2, the reproducer gets an error from read() instead of wrong data.
The bug was introduced in 6.19, hence the stable tags. Both patches apply to current master.
Senjin (2):
fs/ntfs3: map the right page of large folios in ntfs_read_write_run() fs/ntfs3: don't mark pages uptodate when ni_read_frame() fails
fs/ntfs3/frecord.c | 12 ++++++++---- fs/ntfs3/fsntfs.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-)
Signature · 1 line
2.56.0