CVE-2026-46121: mm/damon/sysfs-schemes: protect memcg_path kfree() with damon_sysfs_lock
In the Linux kernel, the following vulnerability has been resolved:
mm/damon/sysfs-schemes: protect memcgpath kfree() with damonsysfslock
Patch series "mm/damon/sysfs-schemes: fix use-after-free for [memcg]path".
Reads of 'memcgpath' and 'path' files in DAMON sysfs interface could race with their writes, results in use-after-free. Fix those.
This patch (of 2):
damonsysfsschemefilter->mmecgpath can be read and written by users, via DAMON sysfs memcgpath file. It can also be indirectly read, for the parameters {on,off}line committing to DAMON. The reads for parameters committing are protected by damonsysfslock to avoid the sysfs files being destroyed while any of the parameters are being read. But the user-driven direct reads and writes are not protected by any lock, while the write is deallocating the memcgpath-pointing buffer. As a result, the readers could read the already freed buffer (user-after-free). Note that the user-reads don't race when the same open file is used by the writer, due to kernfs's open file locking. Nonetheless, doing the reads and writes with separate open files would be common. Fix it by protecting both the user-direct reads and writes with damonsysfslock.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Apply the patch from the series 'mm/damon/sysfs-schemes: fix use-after-free for [memcg_]path' (this patch is described as 'This patch (of 2)') so that memcg_path kfree() is performed while holding damon_sysfs_lock to prevent use-after-free when users read or write the memcg_path sysfs file.
Linux kernel (mm/damon/sysfs-schemes) memcg_path kfree() protection = protect with damon_sysfs_lock - Configuration
Ensure DAMON sysfs interface serializes user-direct reads, writes, and parameter committing (for 'memcg_path' and 'path' files) under damon_sysfs_lock so that readers cannot observe freed buffers and writers cannot free buffers while reads are in progress (as fixed by the 'mm/damon/sysfs-schemes: fix use-after-free for [memcg_]path' patch series).
Linux kernel (mm/damon/sysfs-schemes) DAMON sysfs parameter reads/writes serialization = serialize reads and writes with damon_sysfs_lock
Event History
Frequently Asked Questions
Who is exposed to this issue?
Systems exposing and using the DAMON sysfs interface are affected when concurrent access occurs to the memcg_path or path files. The race is relevant when reads and writes are performed through separate open sysfs file handles.
What does an attacker need to do to trigger the vulnerability?
An attacker needs local, low-privileged access sufficient to read from and write to the relevant DAMON sysfs files. They must race a read against a write that deallocates the path buffer, producing a use-after-free condition.
Does using the same open sysfs file for reads and writes avoid the race?
Yes. Reads and writes through the same open file do not race because of kernfs open-file locking. This does not protect accesses made through separate open file handles.
What is the fix?
The resolved fix protects direct user reads and writes of memcg_path with damon_sysfs_lock, preventing a reader from accessing the buffer after a concurrent write frees it. The advisory also describes a related fix for the DAMON path file.