CVE-2026-90179: apparmor: fix deadlock in complain-mode change_hat
In the Linux kernel, the following vulnerability has been resolved:
apparmor: fix deadlock in complain-mode changehat
The use of changehat when in complain mode can cause a deadlock when the hat doesn't exist and a new learning profile is created for the missing profile. This is because changehat() has taken the lock to search the hat list and creating the new learning profile needs to take the lock to add it to the list.
From the bug report:
Originally found in 7.0.0 in LTS ubuntu 26.04 with pamapparmor + su in complain mode set to change hats. Then verified in newest available vanilla kernel I've compiled to see if still present:
7.2-rc7 vanilla -> affected
checked also some other kernels: 6.18.44 vanilla -> affected 6.12.95 with debian patches -> unaffected
On systems without bug (for example 6.12.95 debian) it just prints:
aachangehat rc=0
On systems with bug, the executable always hangs, prints nothing and becomes unkillable. (And once stuck this way, it will cause any further hat changes to also cause the changing process to get stuck)
Then in syslog you can find hint about cause:
kernel: INFO: task hat:3409 blocked for more than 483 seconds. kernel: Not tainted 7.2.0-rc7 #1 kernel: "echo 0 > /proc/sys/kernel/hungtasktimeoutsecs" disables this message. kernel: task:hat state:D stack:0 pid:3409 tgid:3409 ppid:2605 taskflags:0x400000 flags:0x00080800 kernel: Call Trace: kernel: <TASK> kernel: schedule+0x48f/0xfe0 kernel: schedule+0x27/0xa0 kernel: schedulepreemptdisabled+0x15/0x30 kernel: mutexlock.constprop.0+0x569/0xa10 kernel: aanewlearningprofile+0x15f/0x210 kernel: buildchangehat+0x19f/0x3b0 kernel: changehat.isra.0+0x5dd/0xd60 kernel: aachangehat+0x2f3/0x710 kernel: aasetprocattrchangehat+0x121/0x1f0 kernel: dosetattr+0x28c/0x340 kernel: apparmorsetselfattr+0x20/0x50 kernel: securitysetselfattr+0xf6/0x110 kernel: x64syslsmsetselfattr+0x53/0x90 kernel: dosyscall64+0xdd/0x5e0 kernel: ? modmemcglruvecstate+0xfd/0x260 kernel: ? lruvecstatmodfolio+0x8d/0xd0 kernel: ? foliomodstat+0x2d/0x90 kernel: ? mapanonfolioptenopf+0xd1/0x1f0 kernel: ? doanonymouspage+0x184/0xa10 kernel: ? handlemmfault+0x805/0x870 kernel: ? countmemcgevents+0xef/0x230 kernel: ? handlemmfault+0x1f0/0x2f0 kernel: ? douseraddrfault+0x2bb/0x7b0 kernel: ? dosyscall64+0x94/0x5e0 kernel: ? excpagefault+0x75/0x160 kernel: entrySYSCALL64afterhwframe+0x76/0x7e kernel: RIP: 0033:0x7f815e134c8d kernel: RSP: 002b:00007fff6df94ea8 EFLAGS: 00000246 ORIGRAX: 00000000000001cc kernel: RAX: ffffffffffffffda RBX: 0000556d8c81d040 RCX: 00007f815e134c8d kernel: RDX: 0000000000000046 RSI: 0000556d8c81d040 RDI: 0000000000000064 kernel: RBP: 00007fff6df94ef0 R08: 00007f815e212ac8 R09: 000000000000000c kernel: R10: 0000000000000000 R11: 0000000000000246 R12: 0000556d8c81d010 kernel: R13: 0000000000000026 R14: 0000000000000046 R15: 0000000000000064 kernel: </TASK> kernel: INFO: task hat:3409 is blocked on a mutex likely owned by task hat:3409.
To fix the issue, lift the locking out of the core of aanewlearningprofile(), introduce a wrapper function that takes the lock where needed, and have buildchangehat() call the core function that no longer takes the lock.
In addition fix 4 other issues introduced by commit 32e92764d6f8d ("apparmor: grab ns lock and refresh when looking up changehat child profiles") - aagetprofilercu() was replaced-by: aagetprofile without the accompanying rcudereferenceprotected() - an extra aagetlabel(label) was introduced at the start of changehat() without an accompanying aaputlabel() causing a reference count leak. - a reference count leak was introduced in the labelisstale(label) case, where the newest profile would be leaked instead of the label passed to the function. - a potential UAF when the lookup walks up the tree with newns != ns the new label refere ---truncated---
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.95 - Upgrade
Upgrade
linux kernelto a version that resolves this vulnerability.Fixed in 6.18.44 - Upgrade
Upgrade
linux kernelto a version that resolves this vulnerability.Fixed in 7.2-rc7 - Upgrade
Upgrade
linux kernelto a version that resolves this vulnerability.Patch 32e92764d6f8d - Configuration
Avoid using change_hat when in complain mode, which is explicitly described as causing the deadlock/unresponsive behavior in the bug report excerpt.
AppArmor change_hat in complain mode = disabled
Event History
Frequently Asked Questions
What conditions are required to trigger the deadlock?
AppArmor must be operating in complain mode, and a process must use change_hat for a hat that does not exist. The deadlock occurs when AppArmor attempts to create a learning profile for that missing hat while change_hat holds the hat-list lock.
Which environments are known to be affected or unaffected?
The issue was reported on Ubuntu 26.04 LTS with pam_apparmor and su configured to change hats, and was verified on vanilla 7.2-rc7 and vanilla 6.18.44 kernels. A Debian-patched 6.12.95 kernel was reported as unaffected.
How can I determine whether a system is experiencing this issue?
On an affected system, the executable invoking the missing-hat change can hang without producing output and become unkillable. Subsequent hat changes can also cause their calling processes to hang, and syslog may show a kernel message that a task named "hat" has been blocked for more than 483 seconds.