CVE-2026-99505: apparmor: fix a use-after-free in aa_lookupn_ns()
In the Linux kernel, the following vulnerability has been resolved:
apparmor: fix a use-after-free in aalookupnns()
aalookupnns() takes a reference on the namespace it finds with aagetns(), which is krefget() on the reference count that the namespace is released through, without checking whether the namespace is still in use. A concurrent removal of a ":"-prefixed namespace looks the same namespace up and only then takes the parent lock to remove it, so the last reference can be dropped between the lookup and the aagetns() call: the reference count then reports the increment on a zero count and the kernel classifies the following use of the object as a use-after-free. A user with CAPMACADMIN can trigger this by writing a ":<name>" removal and a ":<name>/<profile>" removal to /sys/kernel/security/apparmor/.remove concurrently.
refcountt: addition on 0; use-after-free. WARNING: lib/refcount.c:25 at refcountwarnsaturate+0xc0/0xe0, CPU#6 Call Trace: <TASK> aalookupnns+0xa9/0xc0 aaremoveprofiles+0x4fb/0x730 ? kvmallocnodenoprof+0x219/0x5c0 ? pfxaaremoveprofiles+0x10/0x10 ? aaloaddataalloc+0x65/0x1f0 ? copyfromuser+0x2d/0x80 ? aaloaddataalloc+0x111/0x1f0 profileremove+0x2ee/0x4a0 vfswrite+0x21e/0xcf0 ? rcucore+0x29c/0x1740 ? timerqueuelinkedadd+0x1f4/0x3d0 ? pfxvfswrite+0x10/0x10 ? mutexlock+0x81/0xe0 ? pfxmutexlock+0x10/0x10 ? pfxrcucore+0x10/0x10 ? pfxhrtimerupdatenextevent+0x10/0x10 ? mutexunlock+0x7b/0xd0 ? fdgetpos+0x24d/0x4b0 ksyswrite+0xf7/0x1c0 ? pfxksyswrite+0x10/0x10 ? restorefpregsfromfpstate+0x37/0xc0 dosyscall64+0xf9/0x540 entrySYSCALL64afterhwframe+0x77/0x7f </TASK>
Fix by rejecting a namespace whose reference count is zero.
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 aa_lookupn_ns(), reject a namespace whose reference count is zero before taking a reference to it.