[PATCH v2 0/6] ntfs: fix the $MFT bootstrap hang and reads of unmapped runlist ranges
From: Matthias Goergens
Date: Sun Sep 27 2026 - 01:08:38 EST
Hi Hyunchul,
This is v2 of "ntfs: fail the mount when $MFT needs its own extent
records", now patch 3. As you suggested, the mark now stays set for the
whole $DATA enumeration in ntfs_read_inode_mount(). A crafted image
that puts $MFT's second $DATA extent in an extent record the first
extent does not cover hung v1 in that loop; with v2 the mount fails.
One correction to v1: lockdep stayed silent not because of the folio
lock, but because ntfs_fill_super() turns it off for the whole mount.
Patch 3 needs patch 1. With clusters smaller than a page, patch 3 can
refuse the tail of a folio holding an $MFT record, and without patch 1
the refused range is mapped as a hole and the mount carries on with an
all-zero mft record.
That hole is not specific to $MFT. Patches 1 and 2 fix it for any file
whose runlist is partly in an extent record that cannot be read: reads
of that range return zeros with no error, and buffered writes into it
report success and are lost. Patch 4 does the same for a runlist that
ends before allocated_size, which a crafted $MFT used to get past patch
3. Patch 5 refuses a $MFT whose data_size exceeds its allocation, and
patch 6 requires initialized_size <= data_size <= allocated_size, with
allocated_size a multiple of the cluster size, for every non-resident
attribute, 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. 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 volumes that mount, at
https://github.com/matthiasgoergens/linux/tree/reproducer/2026-09-26-ntfs-v2-extra
v1: https://lore.kernel.org/all/20260922153931.1976405-1-matthias.goergens@xxxxxxxxx/
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 | 54 +++++++++++++++++++++++++++++++++++++++----
fs/ntfs/attrlist.c | 8 +++++--
fs/ntfs/inode.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
fs/ntfs/iomap.c | 16 +++++++++++--
fs/ntfs/layout.h | 13 +++++++----
fs/ntfs/volume.h | 3 +++
6 files changed, 137 insertions(+), 14 deletions(-)
base-commit: 259abb551e2944998cad4214c201954ab1ac5c8d
--
2.55.0