CVE-2026-143122: perf/core: Do not resurrect cpuctx->cgrp after last cgroup event exit

Published Dec 3, 2026
·
Updated

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

1 affected component
Linux Linux kernel

Event History

Dec 3, 2026
CVE Published
via MITRE·09:19 AM
Data Sourced
via MITRE·09:19 AM
Description

Frequently Asked Questions

1

What conditions are required for this issue to occur?

A cgroup perf event must have a pending disable that has not yet been processed by irq_work, such as after its PERF_EVENT_IOC_REFRESH limit is exhausted. During a cgroup switch, that event must be disabled inline by ctx_sched_out(), and it must be the last cgroup event on the CPU context.

2

How can an affected state be identified?

The inconsistent state is cpuctx->cgrp remaining non-NULL while ctx.nr_cgroups is zero. This occurs when perf_cgroup_event_disable() clears cpuctx->cgrp for the last event, followed by perf_cgroup_switch() assigning it again.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203