CVE-2026-139677: kernfs: don't hold kernfs_rwsem across dir_emit()
In the Linux kernel, the following vulnerability has been resolved:
kernfs: don't hold kernfsrwsem across diremit()
kernfsfopreaddir() holds kernfsrwsem for reading across the whole listing, diremit() included. diremit() copies to userspace, so it can fault into reclaim while holding the lock that every create, remove and rename in the hierarchy needs. sysfs and cgroupfs have one per machine.
Under memory pressure the monitoring daemons fault on their own getdents(2) buffer with it held:
below: page allocation stall for 120 secs: order:0, mode:0x140dca(GFPHIGHUSERMOVABLE|GFPZERO|GFPCOMP) nodemask=(null),cpuset=hostcritical.slice,memsallowed=0 Call Trace: <TASK> dumpstacklvl+0x5d/0x80 allocfrozenpagesnoprof+0x5f4d/0x6300 ? memcglistlrualloc+0x73/0x320 ? imafilecheck+0xd0/0x7d0 vmaallocfolionoprof+0x145/0x560 handlemmfault+0x17c9/0x2720 ? findvma+0x27/0x30 douseraddrfault+0x39f/0x6e0 excpagefault+0x8f/0x110 asmexcpagefault+0x22/0x30 RIP: 0010:filldir64+0xd7/0x1a0 [Code:/RSP:/RAX:..R15: register block elided] kernfsfopreaddir+0x2de/0x420 iteratedir+0x8c/0x1f0 sesysgetdents64+0x61/0xe0 ? copypagefromiter+0x860/0x860 dosyscall64+0x6a/0x250 entrySYSCALL64afterhwframe+0x4b/0x53 </TASK>
Commit 9aab10a0249e ("kernfs: Don't re-lock kernfsroot::kernfsrwsem in kernfsfopreaddir().") took the lock drop out because diremit() was handed kernfsnode::name, which a rename can free. The previous patch emits a copy instead, so drop the lock around diremit().
A listing is no longer atomic within one getdents(2) call, which for most sysfs and cgroup directories is all of it. POSIX leaves that unspecified for an entry added or removed since opendir(3).
Affected Software
Event History
Frequently Asked Questions
Which systems are most exposed to this issue?
Systems using sysfs or cgroupfs are affected by the relevant kernfs hierarchy behavior. The described failure is most likely under memory pressure when monitoring daemons list these filesystems with getdents(2).
What is the likely operational impact?
A userspace directory listing can fault while kernfs_rwsem is held, blocking create, remove, and rename operations in the affected hierarchy. The report shows page-allocation stalls lasting 120 seconds during kernfs_fop_readdir().
Is a mitigation provided for systems that cannot immediately apply the fix?
No alternative mitigation is described. The provided references are stable kernel commits resolving the locking issue.