]> git.ipfire.org Git - thirdparty/linux.git/commit
ntfs: grow index root value before reparent header update
authorDaeMyung Kang <charsyam@gmail.com>
Mon, 8 Jun 2026 15:49:15 +0000 (00:49 +0900)
committerNamjae Jeon <linkinjeon@kernel.org>
Tue, 9 Jun 2026 12:50:57 +0000 (21:50 +0900)
commit0bb508fb3b97e4802ec727fd2af4d608f65dd190
treeea68f621e83f8e16334b470ef12222ce500b639f
parent097cdfd0a55df5af82c9753833f39a8bfadbcfcb
ntfs: grow index root value before reparent header update

ntfs_ir_reparent() moves the resident index root entries into an index
block and leaves a small root stub containing the child VCN. That root
stub can be larger than the existing resident value. For example, an
empty root with value_length 48 has an index area of 32 bytes, while the
large-index root stub needs index_length and allocated_size of 40 bytes.

The current code publishes the larger index.index_length and
index.allocated_size before resizing the resident value. If the resize
returns -ENOSPC, the recovery path can call ntfs_inode_add_attrlist(),
which looks attributes up again while the root header says
allocated_size 40 but the resident value still only provides 32 bytes of
index area. Lookup-time $INDEX_ROOT validation then correctly rejects
that transient layout as corrupt.

This reproduces as a generic/013 failure under qemu. In the failing run,
the transient root had value_len=48, index_size=32, index_length=40, and
allocated_size=40, and ntfsprogs-plus ntfsck reported "Corrupt index
root in MFT record 1177".

When the root stub grows, resize the resident value before publishing the
larger root header. If the resize fails, the old root remains valid for
recovery lookups. Keep the existing header-before-resize ordering for
shrink or same-size cases so the resident value never temporarily
exposes an allocated_size beyond its bounds.

Cc: stable@vger.kernel.org # v7.1
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/index.c