CVE-2026-99848: apparmor: fix NULL ctx->peer derefs in unix socket ctx updates
In the Linux kernel, the following vulnerability has been resolved:
apparmor: fix NULL ctx->peer derefs in unix socket ctx updates
aaunixfileperm lazily refreshes the AppArmor context cached on a unix socket. Two of the helpers it uses assume ctx->peer has already been set:
updatepeerctx -> l = aalabelmerge(old, label, GFPATOMIC); updateskctx -> } else if (aalabelissubset(plabel, old)) {
where @old is ctx->peer. Neither aalabelmerge nor aalabelissubset allows NULL. So both fault on the aalabel->size load.
BUG: kernel NULL pointer dereference, address: 000000000000004c RIP: 0010:aalabelnextnotinset+0xb/0xd0 Call Trace: aalabelissubset+0x3f/0x70 aaunixfileperm+0x5e8/0x9d0 aafileperm+0x45a/0x550 apparmorfilepermission+0x44/0xb0 securityfilepermission+0x40/0x100 rwverifyarea+0x56/0x180 vfswrite+0x7c/0x480 ksyswrite+0xbf/0xf0
ctx->peer is only recorded for stream connections and socket pairs. unixdgramconnect sets unixpeer(sk) without going through that path, so a connected AFUNIX datagram socket has unixpeer(sk) set while ctx->peer is still NULL, and the first write that needs revalidation reaches the helpers above.
Both derefs date back to the Fixes: commit, but the updateskctx() one was dormant until commit 4483efe4f215 ("apparmor: fix shadowing of plabel that prevents cache from being updated") stopped @plabel being shadowed, which is why bisecting the oops lands there.
A NULL @old just means no peer label has been recorded yet, so install the label directly instead of merging or comparing against it.