[REGRESSION] ntfs3: delalloc support reintroduces infinite loop in ntfs_compress_write
From: まだ春を待つ
Date: Sun Dec 06 2026 - 04:37:15 EST
Hi Konstantin,
ntfs3 in v7.3.7 (and v7.3.4) hangs in ntfs_compress_write() on a compressed
file whose sparse run does not advance i_valid. This is the same hang as
syzbot bcf9e1868c1a0c7e04f1 (no CVE assigned), which was fixed by
27b75ca4e51e ("fs/ntfs3: prevent infinite loops caused by the next valid
being the same").
The guard added by that commit is missing from the v7.3.7 source:
if (lcn == SPARSE_LCN) {
ni->i_valid = valid =
frame_vbo + ((u64)clen << sbi->cluster_bits);
continue;
}
It was removed by 10d7c95af043 ("fs/ntfs3: add delayed-allocation
(delalloc) support"):
@@ -1011,17 +1026,13 @@ static ssize_t ntfs_compress_write(...)
if (lcn == SPARSE_LCN) {
- valid = frame_vbo + ((u64)clen << sbi->cluster_bits);
- if (ni->i_valid == valid) {
- err = -EINVAL;
- goto out;
- }
- ni->i_valid = valid;
+ ni->i_valid = valid =
+ frame_vbo + ((u64)clen << sbi->cluster_bits);
continue;
}
10d7c95af043 is a direct descendant of 27b75ca4e51e (7 commits later),
so this is not a merge artifact: the delalloc change explicitly dropped
the progress check. The commit was merged by 75a452d31ba6 ("Merge tag
'ntfs3_for_7.0'").
I verified that the v7.3.7 tree is the official kernel.org tarball, not a
locally modified tree:
- linux-7.3.7.tar.xz sha256:
c4cbb90c12f90d59e49320b9ab0b5e7b7de0c15dd56ede5bc0c81ba16b30e59d
(matches kernel.org v7.x/sha256sums.asc)
- fs/ntfs3/file.c sha256:
5c0ebe77ae1440476ceb4dc42332dc547a4805026dfd3339be9f93e42c90e3b3
(identical in tarball and tree)
- fs/ntfs3 directory matches the tarball byte-for-byte apart from build
artifacts (.o/.cmd/built-in.a)
Dynamic A/B with the same 64MiB NTFS image and trigger:
- v7.3.7: mount succeeds; pwrite(fd, "A", 1, 0x2000) never returns. The
first writer stays R at 99.9% CPU; a second writer is D in
ntfs_file_write_iter (stack: ntfs_file_write_iter -> vfs_write ->
ksys_pwrite64). The 7.3.7 build has CONFIG_DETECT_HUNG_TASK=n, so there
is no automatic 143-second hung-task warning.
- v6.18.66: same image and trigger, pwrite returns -1/EINVAL immediately;
no D-state task.
Reproducer details:
- 64MiB NTFS image, 512-byte sector, 4KiB cluster.
- /trigger has a compressed non-resident unnamed $DATA:
alloc_size=0x3000, data_size=0x3000, valid_size=0x1000.
- runlist: VCN 0 sparse, 1 cluster; VCN 1 data, 1 cluster (LCN 0x2200).
- trigger: pwrite(fd, "A", 1, 0x2000).
The image and small build/patch/trigger scripts are available. I can send
the scripts inline or the image on request; I did not attach the 64MiB
image to avoid list size limits.
A minimal fix is to restore the guard (or an equivalent progress check)
in ntfs_compress_write():
if (lcn == SPARSE_LCN) {
valid = frame_vbo + ((u64)clen << sbi->cluster_bits);
if (ni->i_valid == valid) {
err = -EINVAL;
goto out;
}
ni->i_valid = valid;
continue;
}
This also affects v7.3.4 and current master; v6.18.66 is not affected.
#regzbot introduced: 10d7c95af043b45a85dc738c3271bf760ff3577e
#regzbot title: ntfs3: delalloc support reintroduces infinite loop in ntfs_compress_write
#regzbot link: https://syzkaller.appspot.com/bug?extid=bcf9e1868c1a0c7e04f1
Thanks,
kkU1444
1691565877@xxxxxx
Attachment:
COMPRESS-WRITE-evidence-20261206.zip
Description: Binary data
Attachment:
COMPRESS-WRITE-REGRESSION-20261206.md
Description: Binary data
Attachment:
SHA256SUMS
Description: Binary data