ntfs: fix the $MFT bootstrap hang and reads of unmapped runlist ranges
Status from this message: Applied them to #ntfs-next.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest6 patches 2 repliesApplied
- v26 patches 6 repliesSuperseded
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | ntfs: do not map an unmappable runlist fragment as a holefs/ | +22 | 0 replies | |
| 2/6 | ntfs: do not turn an unmappable runlist fragment into delalloc on writefs/ | +14 | 0 replies | |
| 3/6 | ntfs: fail the mount when $MFT needs its own extent recordsfs/ fs/ fs/ | +23 | 0 replies | |
| 4/6 | ntfs: do not map a vcn as a hole when its runlist lookup failedfs/ fs/ | +26 | 0 replies | |
| 5/6 | ntfs: fail the mount when $MFT's data size exceeds its allocationfs/ | +10 | 0 replies | |
| 6/6 | ntfs: reject non-resident attributes whose sizes exceed their allocationfs/ fs/ | +35 | 0 replies |
Reviews trailers per patch
None of the 6 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Hyunchul Lee |
|---|---|
| Series | R-b |
| 1/6 | |
| 2/6 | |
| 3/6 | |
| 4/6 | |
| 5/6 | |
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/6] ntfs: fix the $MFT bootstrap hang and reads of unmapped runlist ranges
Hi Hyunchul,
This is v3, with your review of v2 and Baolin's applied:
- Patch 1: a failed retry for a vcn at or beyond allocated_size returns the runlist end again, as in ntfs-next; only lookups below it fail with -EIO. On its own, v2's patch 1 also failed lookups past EOF, for instance when reading a file's last folio with 512-byte clusters (Baolin). Baolin suggested moving patch 4's allocated_size check before the retry instead, but that skips a retry ntfs-next makes: on a corrupt volume whose allocated_size is cut to where a file's last extent record starts, the rest of the file was then read as zeros, where ntfs-next and v3's patch 1 read the data (with the whole series, patch 6 rejects that file).
- Patch 4: the if statement you asked me to merge is gone, as the allocated_size check now sits in patch 1, and in ntfs_attr_vcn_to_rl() patch 4 only extends patch 1's -EIO to LCN_ENOENT. The expansion rollback restores allocated_size under size_lock.
- Patch 6: the comment is gone, and $MFT's own non-resident attribute list is checked too (Baolin); a volume where that list claims more data than its allocation used to mount and now fails to.
Patches 2, 3 and 5 are unchanged.
The series fixes a hang at mount when $MFT needs its own extent records (patch 3, which needs patch 1). Patches 1 and 2 fix reads and writes of a runlist range held in an extent record that cannot be read, which returned zeros with no error or silently lost buffered writes, and patch 4 does the same for a runlist that ends before allocated_size. Patches 5 and 6 check the sizes of $MFT's data and of every non-resident attribute against their allocation, as fs/ntfs3 does.
Tested under qemu with KASAN and the hung-task detector on ntfs-next, with and without the series. Nine crafted images that hang or crash the mount without it fail to mount with it, and six that read zeros that are not on disk return errors instead. Eighteen images that mount without the series, among them eight public test volumes written by Windows or mkntfs, read every file the same with it, and six small mkntfs images still mount. v3 gives the same results as v2 on all of them. The images and the scripts that generate them are at
https://github.com/matthiasgoergens/linux/tree/reproducer/2026-09-26-ntfs-mft-runlist
and, for the ordinary file of patch 4, the unaligned allocated_size of patch 6 and three of the eighteen volumes that mount, at
https://github.com/matthiasgoergens/linux/tree/reproducer/2026-09-26-ntfs-v2-extra
and, for v3's changes, at
https://github.com/matthiasgoergens/linux/tree/reproducer/2026-09-30-ntfs-v3
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
Thanks,
Matthias
Matthias Goergens (6):
ntfs: do not map an unmappable runlist fragment as a hole
ntfs: do not turn an unmappable runlist fragment into delalloc on
write
ntfs: fail the mount when $MFT needs its own extent records
ntfs: do not map a vcn as a hole when its runlist lookup failed
ntfs: fail the mount when $MFT's data size exceeds its allocation
ntfs: reject non-resident attributes whose sizes exceed their
allocation
fs/ntfs/attrib.c | 51 +++++++++++++++++++++++++++++++++++++++++----- fs/ntfs/attrlist.c | 8 ++++++-- fs/ntfs/inode.c | 46 +++++++++++++++++++++++++++++++++++++++++ fs/ntfs/iomap.c | 16 +++++++++++++-- fs/ntfs/layout.h | 13 +++++++----- fs/ntfs/volume.h | 3 +++ 6 files changed, 123 insertions(+), 14 deletions(-)
base-commit: 259abb551e2944998cad4214c201954ab1ac5c8d
Signature · 1 line
2.55.0