CVE-2026-99556: ksmbd: serialize directory emptiness checks with readdir
In the Linux kernel, the following vulnerability has been resolved:
ksmbd: serialize directory emptiness checks with readdir
SMB2 QUERYDIRECTORY holds fp->readdirlock while it calls iteratedir() on fp->filp. An SMB2 SETINFO request with FILEDISPOSITIONINFORMATION can resolve the same FileId and call ksmbdvfsemptydir() on the same filp without that lock.
iteratedir()'s inode read lock permits concurrent readers and does not serialize per-file iterator state. ext4 stores its dx readdir cursor and fname RB tree in file->privatedata. Concurrent reset or refill can therefore free a fname node while the other worker still traverses it or retains its RB-tree link, resulting in use-after-free accesses.
An authenticated SMB client with list and delete rights on a directory in a writable KSMBD share backed by ext4 can trigger this when the directory takes the dx readdir path. The client overlaps an SMB2 QUERYDIRECTORY request with an SMB2 SETINFO request carrying FILEDISPOSITIONINFORMATION on one live FileId.
In one x8664 SMP KASAN multi-shot guest using ksmbd-for-next at 171df27077fb, the unmodified kernel reported a cross-worker use-after-free before a panic. The first report's access and free stacks show the two request paths directly (trimmed):
BUG: KASAN: slab-use-after-free in ext4htreestoredirent+0x488/0x550 Read of size 8 by task kworker/2:0/29 Workqueue: ksmbd-io handleksmbdwork Call Trace: ext4htreestoredirent+0x488/0x550 htreedirblocktotree+0x535/0x990 ext4htreefilltree+0x319/0xba0 ext4readdir+0x175a/0x2f40 iteratedir+0x1b6/0x630 smb2querydir+0x1003/0x1cc0
Freed by task 279: freerbtreefname+0x67/0xc0 ext4readdir+0x13a9/0x2f40 iteratedir+0x1b6/0x630 ksmbdvfsemptydir+0xa2/0x100 smb2setinfo+0x2ffa/0x45d0
Take fp->readdirlock across the entire emptiness check. This places both iterators over that handle's filp in the same lock domain while preserving the disposition status handling. The exact code change completed a warning-free x8664 KASAN bzImage build. Tracing three request pairs showed that the two iteratedir() calls no longer overlapped and the expected statuses were preserved. A further 1,600 reproducer iterations completed with expected statuses and no KASAN report, Oops, or panic.
The reproducer and complete guest configuration are available privately to maintainers on request.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.117 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.61 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.2 - Compensating control
In ksmbd, hold fp->readdir_lock across the entire directory-emptiness check in ksmbd_vfs_empty_dir() so iterators over the same filp are serialized.