CVE-2026-64419: mm/shrinker: do not hold RCU lock in shrinker_debugfs_count_show()
In the Linux kernel, the following vulnerability has been resolved:
mm/shrinker: do not hold RCU lock in shrinkerdebugfscountshow()
Reading the debugfs "count" file of a memcg-aware shrinker can sleep inside an RCU read-side critical section:
BUG: sleeping function called from invalid context at kernel/cgroup/rstat.c:421 RCU nest depth: 1, expected: 0 cssrstatflush memcgroupflushstats zswapshrinkercount shrinkerdebugfscountshow
shrinkerdebugfscountshow() invokes the ->countobjects() callback under rcureadlock(). The zswap callback flushes memcg stats via cssrstatflush(), which may sleep, so it must not run under RCU.
The RCU lock is not needed here. memcgroupiter() takes RCU internally and returns a memcg holding a css reference (dropped on the next iteration or by memcgroupiterbreak()), so the memcg stays alive without it. The shrinker is kept alive by the open debugfs file: shrinkerfree() removes the debugfs entries via debugfsremoverecursive(), which waits for in-flight readers to drain, before callrcu(..., shrinkerfreercucb). The sibling "scan" handler already invokes the sleeping ->scanobjects() callback with no RCU section.
Drop the rcureadlock()/rcureadunlock().
Affected Software
Remediation
Event History
Frequently Asked Questions
Who is exposed to this issue?
Systems are exposed when a user can read the debugfs "count" file for a memcg-aware shrinker. The described failing path involves the zswap shrinker, whose count callback can flush memory-cgroup statistics.
What does an attacker or local user need to do to trigger it?
They need local access sufficient to read the affected shrinker debugfs "count" file. Reading that file can invoke the shrinker's count callback while an RCU read-side critical section is held.
How can I tell whether the issue has occurred?
Kernel logs may report "BUG: sleeping function called from invalid context" and show an RCU nesting depth of 1. The reported stack includes css_rstat_flush, mem_cgroup_flush_stats, zswap_shrinker_count, and shrinker_debugfs_count_show.
What should I do if I cannot patch immediately?
Avoid reading the debugfs "count" file for memcg-aware shrinkers, particularly where it invokes the zswap shrinker count callback. A patch is available.