{"id":"CVE-2026-143122","summary":"perf/core: Do not resurrect cpuctx-\u003ecgrp after last cgroup event exit","details":"In the Linux kernel, the following vulnerability has been resolved:\n\nperf/core: Do not resurrect cpuctx-\u003ecgrp after last cgroup event exit\n\nperf_cgroup_switch() relies on:\n\n    /*\n     * cpuctx-\u003ecgrp is set when the first cgroup event enabled,\n     * and is cleared when the last cgroup event disabled.\n     */\n\nIt computes the next task's cgroup, schedules out the CPU context and\nthen assigns cpuctx-\u003ecgrp unconditionally:\n\n    ctx_sched_out(&cpuctx-\u003ectx, NULL, EVENT_ALL|EVENT_CGROUP);\n    /*\n     * must not be done before ctxswout due\n     * to update_cgrp_time_from_cpuctx() in\n     * ctx_sched_out()\n     */\n    cpuctx-\u003ecgrp = cgrp;\n\nHowever, ctx_sched_out() can disable events itself. If a cgroup event\nhas a pending disable from perf_event_disable_inatomic() (e.g. its\nPERF_EVENT_IOC_REFRESH limit ran out) that the irq_work has not\nhandled yet, event_sched_out() consumes it inline:\n\n    if (event-\u003epending_disable) {\n        event-\u003epending_disable = 0;\n        perf_cgroup_event_disable(event, ctx);\n        state = PERF_EVENT_STATE_OFF;\n    }\n\nIf that was the last cgroup event, perf_cgroup_event_disable() clears\ncpuctx-\u003ecgrp:\n\n    if (--ctx-\u003enr_cgroups)\n        return;\n\n    cpuctx-\u003ecgrp = NULL;\n\nand perf_cgroup_switch() then sets it again. cpuctx-\u003ecgrp is left\nnon-NULL with ctx.nr_cgroups == 0, so the NULL check in\nperf_cgroup_switch() no longer catches it and the next switch trips:\n\n    WARN_ON_ONCE(cpuctx-\u003ectx.nr_cgroups == 0);\n\ncpuctx-\u003ecgrp does not hold a reference on the cgroup. Once that cgroup\nis removed, the next ctx_sched_in() dereferences the stale pointer:\n\n  BUG: KASAN: slab-use-after-free in ctx_sched_in+0xb1f/0xfa0\n  Read of size 8 at addr ffff8881008972d0 by task swapper/3/0\n\n  Tainted: [W]=WARN\n  Call Trace:\n   \u003cIRQ\u003e\n   ctx_sched_in+0xb1f/0xfa0\n   perf_event_sched_in+0x1a/0x70\n   ctx_resched+0x32b/0xac0\n   __perf_install_in_context+0x475/0xab0\n   remote_function+0x105/0x200\n   __flush_smp_call_function_queue+0x179/0x8d0\n   __sysvec_call_function_single+0x1b/0x1c0\n   sysvec_call_function_single+0x66/0x80\n   \u003c/IRQ\u003e\n   \u003cTASK\u003e\n   asm_sysvec_call_function_single+0x1a/0x20\n\nOnly assign cpuctx-\u003ecgrp when cgroup events remain after the context\nhas been scheduled out, so that it stays NULL as the invariant\nrequires.","modified":"2026-12-03T11:01:20.218197191Z","published":"2026-12-03T09:19:33.369Z","database_specific":{"cna_assigner":"Linux","osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/143xxx/CVE-2026-143122.json"},"references":[{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"},{"type":"WEB","url":"https://git.kernel.org/stable/c/1c7567304c778e347c16a819cec83250118ebf17"},{"type":"WEB","url":"https://git.kernel.org/stable/c/59f1398140869432c7171b9a2a279ca315467c4e"},{"type":"WEB","url":"https://git.kernel.org/stable/c/84ef23287df05f2086af7a21eb6a6d44a095f119"},{"type":"WEB","url":"https://git.kernel.org/stable/c/b06c73f3d18edbf3ca40fbbadc8740757465ee5c"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/143xxx/CVE-2026-143122.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-143122"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"e19cd0b6fa5938c51d7b928010d584f0de93913a"},{"fixed":"b06c73f3d18edbf3ca40fbbadc8740757465ee5c"},{"fixed":"1c7567304c778e347c16a819cec83250118ebf17"},{"fixed":"84ef23287df05f2086af7a21eb6a6d44a095f119"},{"fixed":"59f1398140869432c7171b9a2a279ca315467c4e"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-143122.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.18.0"},{"fixed":"6.12.120"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.13.0"},{"fixed":"6.18.66"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.19.0"},{"fixed":"7.3.7"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-143122.json"}}],"schema_version":"1.9.2"}