Linux filesystem development
 help / color / mirror / Atom feed
From: Senjin <senjin@hatchling.org>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: Senjin <senjin@hatchling.org>,
	ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org
Subject: [PATCH 0/2] fs/ntfs3: fix silent corruption reading compressed files
Date: 21 Oct 2026 04:58:19 -0000	[thread overview]
Message-ID: <6ad8466b98bc0030487babd5@mailersend.net> (raw)

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(-)

-- 
2.56.0

                 reply	other threads:[~2026-10-21  4:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ad8466b98bc0030487babd5@mailersend.net \
    --to=senjin@hatchling.org \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox