Hello, `exfat_readdir()` advances the FAT chain to the requested position before checking `max_dentries`. With 512-byte clusters, a seek to `0x1fffffffe0` becomes dentry `0xffffffff` and a cluster offset of `0x0fffffff` (268,435,455). If the child directory's FAT entry points to itself, every lookup succeeds and the initial `exfat_chain_advance()` performs the full walk while `s_lock` is held. This is a very large but finite walk, not an infinite loop. In two vulnerable QEMU TCG runs, the maximum-offset call timed out after 30 seconds. At a smaller seek, a concurrent create on the same mount was blocked for about 10.6 seconds. The acyclic image and offset-zero controls returned promptly. With this patch, the same maximum-offset call returns in 0 ms, the offset-zero case still returns 48 bytes, and the concurrent create completes in 8 ms. This requires a privileged mount of a crafted exFAT image; after the mount, the trigger is an ordinary seek and `getdents64()`. It causes a local availability problem and does not demonstrate memory corruption, information disclosure, or privilege escalation. This is distinct from CVE-2024-57940, which stops a cycle in the normal directory scan after an unused entry is reached. This trigger occurs before that scan, during the initial seek-to-cluster advance. It is also distinct from CVE-2025-38692, whose cycle checks cover other directory chain scans. The relevant change here is commit 8534eb11ac056 ("exfat: fix reading a directory whose FAT chain is longer than its size"), which makes `exfat_chain_advance()` follow the FAT past the recorded directory size. Tested source revision: HEAD commit: 7cd8495c0f16275c4f9abe1cef09a7b5fcd6d046 source version: Linux 7.4.0-rc4 compiler: gcc 11.4.0, GNU ld 2.38 QEMU: 6.2.0, x86-64 TCG Vulnerable cyclic-image output: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/b782f7cfce5adccf6fb27e8f77af681ae9a56bdf/vulnerable-cycle-console.txt Acyclic control output: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/c2be5849d1d01d8b89e8bff5d4cccd60caf448cf/vulnerable-acyclic-control-console.txt Offset-zero control output: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/499bed78177b3fb513c75fec7af5a61f77f3d7fd/vulnerable-offset-control-console.txt Patched cyclic-image output: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/91bdaf1ea250fef11a6deb8d3096345165073a8d/fixed-cycle-console.txt Patched lock-check output: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/cfe770f5a903913cfd36e1cb081a6dd7e73bb98a/fixed-lock-cycle-console.txt Kernel config: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/82d5e04b73bb0fa00b43ffe100024197cfc46394/kernel-config.txt Reproducer: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/7225d608a822e98e4ad9649d7a0565765517ffdf/poc.c Image builder: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/9d1ebddf4ce0d134e35964e31c1e4f6d1e295bf0/make_image.py Init program: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/e225e0f9f673792dcf1f0551da9c93964b21abb4/init.c Initramfs builder: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/1c12184547861bf626757218d0a14a89c0ead7e7/build_initramfs.sh QEMU runner: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/b5d490fc9b16b90011826cc4d69fefcc28793c1d/run_qemu.sh Patch file: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/7391b06618e00360b66129d5dc905e411591f002/fix.patch Related-cycle checks: https://gist.githubusercontent.com/shaos26/d4b02e7959f89c86725e379c1abb6a96/raw/dab890b4c94021f8c6a7ea3321801d040720dd5e/duplicate-analysis.md The Gist includes patched acyclic, offset-zero, and lock controls. To reproduce, run: work=$(mktemp -d /tmp/exfat-seek.XXXXXX) cd "$work" gist_id=d4b02e7959f89c86725e379c1abb6a96 gist_revision=289ecee4fb5d9acfccb1e705fa517d1c78744f5c gist_base=https://gist.githubusercontent.com/shaos26 gist=$gist_base/$gist_id/raw/$gist_revision for file in kernel-config.txt poc.c init.c make_image.py \ build_initramfs.sh run_qemu.sh fix.patch; do curl -fL "$gist/$file" -o "$file" done git clone \ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cd linux git checkout 7cd8495c0f16275c4f9abe1cef09a7b5fcd6d046 mkdir build cp ../kernel-config.txt build/.config make O=build olddefconfig make O=build -j"$(nproc)" bzImage cd .. sh ./build_initramfs.sh "$PWD/repro" sh ./run_qemu.sh linux/build/arch/x86/boot/bzImage \ repro/initramfs.cpio.gz cycle cycle.log sh ./run_qemu.sh linux/build/arch/x86/boot/bzImage \ repro/initramfs.cpio.gz acyclic acyclic.log To verify the patch, run `git apply --check ../fix.patch` and `git apply ../fix.patch` from the Linux source directory, rebuild, then rerun with `cycle`, `offset0`, and `lock-cycle`. The run scripts capture the QEMU console in the specified log file. Return before walking the FAT when the requested position exceeds the maximum dentry count: Fixes: 8534eb11ac05 ("exfat: fix reading a directory whose FAT chain is longer than its size") Cc: stable@vger.kernel.org Signed-off-by: Shawn Shao --- fs/exfat/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 46514b13bebda..bdbbcd1465fb5 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -90,6 +90,10 @@ static int exfat_readdir(struct inode *inode, loff_t *cpos, struct exfat_dir_ent max_dentries = (unsigned int)min_t(u64, MAX_EXFAT_DENTRIES, exfat_cluster_to_dentries(sbi, sbi->num_clusters)); + /* Don't walk the FAT beyond the maximum dentry count. */ + if (dentry >= max_dentries) + goto out; + clu_offset = exfat_dentries_to_cluster(sbi, dentry); exfat_chain_dup(&clu, &dir); -- 2.34.1 Thanks, Shawn