CVE-2026-142796: mm/slab: sample slab_state once in kmem_cache_destroy()
In the Linux kernel, the following vulnerability has been resolved:
mm/slab: sample slabstate once in kmemcachedestroy()
kmemcacherelease() tests slabstate >= FULL after kmemcachedestroy() has dropped slabmutex and unlinked the cache, and for a SLABTYPESAFEBYRCU cache after rcubarrier(). If slablateinit() runs before that test it sets slabstate to FULL but skips the unlinked cache, which never got a sysfs entry, so sysfsslabrelease() calls kobjectput() on a kobject that was never initialized:
WARNING: lib/kobject.c:734 at kobjectput+0x64/0x2c0, CPU#1: kworker/u8:3/55 kobject: '(null)' ((ptrval)): is not initialized, yet kobjectput() is being called. refcountt: underflow; use-after-free. kobjectput+0x64/0x2c0 sysfsslabrelease+0xc/0x20 kmemcachedestroy+0x104/0x1e0 biosetexit+0x13c/0x1e0 diskrelease+0x54/0x140 putdisk+0x18/0x40 floppyasyncinit+0xbec/0xd10
slabstate >= FULL asks whether the cache has a kobject, which cache creation skips while slabstate <= UP. UP is the state just below FULL, so a false sample cannot skip a kobjectput() that was owed.
Seen on sparc64 at boot, where the asynchronous floppy init tears down its bio slab while the late initcalls are running.
Sample slabstate once, under slabmutex which slablateinit() holds when it sets FULL, and use the result for both the unlink and the release.
The history of this problem dates back to v3.2:
Commit 69cb8e6b7c29 ("slub: free slabs without holding locks") in v3.2 moved sysfsslabremove() outside slublock and introduced a race condition between kmemcachedestroy() and slabsysfsinit().
Commit 945cf2b6199be ("mm/sl[aou]b: Extract a common function for kmemcachedestroy") in v3.7 accidentally closed the race while extracting a common implementation for kmemcachedestroy().
Commit 5413dfba88d6 ("slub: drop mutex before deleting sysfs entry") in v3.8 re-opened the race by dropping slabmutex around sysfsslabremove() in kmemcacheshutdown(), to avoid a lockdep splat between slabmutex and the sysfs lock.
Commit 657dc2f97220 ("slab: remove synchronous rcubarrier() call in memcg cache release path") in v4.11 shifted from synchronous rcubarrier() to asynchronous RCU work for SLABTYPESAFEBYRCU caches. That commit, again, accidentally closed the race by moving sysfsslabrelease() to shutdowncache(), but only for !SLABTYPESAFEBYRCU caches because destruction of SLABTYPESAFEBYRCU caches is done in an RCU work.
Commit 0495e337b703 ("mm/slabcommon: Deleting kobject in kmemcachedestroy() without holding slabmutex/cpuhotpluglock") in v6.0 re-introduced the race for !SLABTYPESAFEBYRCU caches.
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 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.117-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 7.3.3-1 - Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 6.12.117-1Fixed in 7.3.3-1
Event History
Frequently Asked Questions
Under what conditions can the race occur?
The race requires a slab cache to be created while slab_state is at or below UP, so it has no sysfs kobject, then to be unlinked and destroyed while slab_late_init() advances slab_state to FULL before kmem_cache_release() checks it. The reported path includes destruction of a SLAB_TYPESAFE_BY_RCU cache after rcu_barrier().
What systems or workloads are most likely to encounter it?
It was observed during boot on sparc64, where asynchronous floppy initialization tore down its bio slab while slab initialization was still progressing. Any kernel execution that overlaps cache teardown with slab_late_init() may be relevant; the provided data does not identify a broader architecture-specific scope.
How can I tell whether the issue has occurred?
Kernel logs may show a WARNING in lib/kobject.c at kobject_put(), stating that an uninitialized kobject is being passed to kobject_put(). The report also describes refcount underflow and use-after-free symptoms, with stack frames including sysfs_slab_release(), kmem_cache_destroy(), and kobject_put().