AZL-118142: CVE-2026-143122 affecting package kernel 6.6.161.1-1
In the Linux kernel, the following vulnerability has been resolved:
perf/core: Do not resurrect cpuctx->cgrp after last cgroup event exit
perfcgroupswitch() relies on:
/ cpuctx->cgrp is set when the first cgroup event enabled, and is cleared when the last cgroup event disabled. /
It computes the next task's cgroup, schedules out the CPU context and then assigns cpuctx->cgrp unconditionally:
ctxschedout(&cpuctx->ctx, NULL, EVENTALL|EVENTCGROUP); / must not be done before ctxswout due to updatecgrptimefromcpuctx() in ctxschedout() / cpuctx->cgrp = cgrp;
However, ctxschedout() can disable events itself. If a cgroup event has a pending disable from perfeventdisableinatomic() (e.g. its PERFEVENTIOCREFRESH limit ran out) that the irqwork has not handled yet, eventschedout() consumes it inline:
if (event->pendingdisable) { event->pendingdisable = 0; perfcgroupeventdisable(event, ctx); state = PERFEVENTSTATEOFF; }
If that was the last cgroup event, perfcgroupeventdisable() clears cpuctx->cgrp:
if (--ctx->nrcgroups) return;
cpuctx->cgrp = NULL;
and perfcgroupswitch() then sets it again. cpuctx->cgrp is left non-NULL with ctx.nrcgroups == 0, so the NULL check in perfcgroupswitch() no longer catches it and the next switch trips:
WARNONONCE(cpuctx->ctx.nrcgroups == 0);
cpuctx->cgrp does not hold a reference on the cgroup. Once that cgroup is removed, the next ctxschedin() dereferences the stale pointer:
BUG: KASAN: slab-use-after-free in ctxschedin+0xb1f/0xfa0 Read of size 8 at addr ffff8881008972d0 by task swapper/3/0
Tainted: [W]=WARN Call Trace: <IRQ> ctxschedin+0xb1f/0xfa0 perfeventschedin+0x1a/0x70 ctxresched+0x32b/0xac0 perfinstallincontext+0x475/0xab0 remotefunction+0x105/0x200 flushsmpcallfunctionqueue+0x179/0x8d0 sysveccallfunctionsingle+0x1b/0x1c0 sysveccallfunctionsingle+0x66/0x80 </IRQ> <TASK> asmsysveccallfunctionsingle+0x1a/0x20
Only assign cpuctx->cgrp when cgroup events remain after the context has been scheduled out, so that it stays NULL as the invariant requires.
Affected Software
Event History
Frequently Asked Questions
What runtime conditions are involved in reaching the flaw?
The issue involves perf cgroup events during a cgroup switch when the last cgroup event has a pending disable. One example given is a PERF_EVENT_IOC_REFRESH limit expiring before its irq_work is handled, causing the disable to be consumed during context scheduling.
Which systems are identified as affected?
The advisory identifies the Azure Linux kernel package version 6.6.161.1-1. The affected code is in the kernel perf subsystem's cgroup-event handling.