CVE-2025-39821: perf: Avoid undefined behavior from stopping/starting inactive events
In the Linux kernel, the following vulnerability has been resolved:
perf: Avoid undefined behavior from stopping/starting inactive events
Calling pmu->start()/stop() on perf events in PERF_EVENT_STATE_OFF can
leave event->hw.idx at -1. When PMU drivers later attempt to use this
negative index as a shift exponent in bitwise operations, it leads to UBSAN
shift-out-of-bounds reports.
The issue is a logical flaw in how event groups handle throttling when some
members are intentionally disabled. Based on the analysis and the
reproducer provided by Mark Rutland (this issue on both arm64 and x86-64).
The scenario unfolds as follows:
1. A group leader event is configured with a very aggressive sampling
period (e.g., sample_period = 1). This causes frequent interrupts and
triggers the throttling mechanism.
2. A child event in the same group is created in a disabled state
(.disabled = 1). This event remains in PERF_EVENT_STATE_OFF.
Since it hasn't been scheduled onto the PMU, its event->hw.idx remains
initialized at -1.
3. When throttling occurs, perf_event_throttle_group() and later
perf_event_unthrottle_group() iterate through all siblings, including
the disabled child event.
4. perf_event_throttle()/unthrottle() are called on this inactive child
event, which then call event->pmu->start()/stop().
5. The PMU driver receives the event with hw.idx == -1 and attempts to
use it as a shift exponent. e.g., in macros like PMCNTENSET(idx),
leading to the UBSAN report.
The throttling mechanism attempts to start/stop events that are not
actively scheduled on the hardware.
Move the state check into perf_event_throttle()/perf_event_unthrottle() so
that inactive events are skipped entirely. This ensures only active events
with a valid hw.idx are processed, preventing undefined behavior and
silencing UBSAN warnings. The corrected check ensures true before
proceeding with PMU operations.
The problem can be reproduced with the syzkaller reproducer:
Security readout for executives and security teams
Plain-English summary
A local, low-privileged user can trigger incorrect Linux performance-monitoring behavior involving disabled events. The kernel may pass an invalid hardware index to processor-specific code, causing undefined bit-shift operations. The supplied CVSS rating is 7.8 (high), although the sources demonstrate UBSAN warnings rather than a confirmed path to system compromise.
Executive priority
Treat this as a high-priority kernel maintenance issue for shared or otherwise locally accessible systems. Schedule vendor-approved updates promptly, but avoid emergency internet-facing-incident assumptions: exploitation requires local access, and the supplied evidence does not show active exploitation or confirmed compromise.
Technical view
Perf event group throttling and unthrottling processed sibling events still in PERF_EVENT_STATE_OFF. Their unscheduled hardware index remained -1, which PMU drivers could use as a shift exponent, producing undefined behavior. The correction moves state validation into the throttle and unthrottle functions so inactive events are skipped. The issue was reproduced on arm64 and x86-64.
Likely exposure
Systems running affected Linux 6.16-series versions may be exposed when local users can create and manipulate perf event groups. The supplied affected-version data is ambiguous around exact boundaries, so distribution backports and kernel build provenance must be checked individually.
Exploitation context
The issue requires local access with low privileges according to the supplied CVSS vector. A syzkaller reproducer and UBSAN reports exist, but no exploit procedure is provided. The CVE is not listed as KEV, and the supplied sources do not establish active exploitation or demonstrated confidentiality, integrity, or availability impact.
Researcher notes
The documented failure is an invalid negative shift index arising from lifecycle-state confusion, while the supplied classification is CWE-787. Assess the underlying undefined behavior independently from the CVSS impact claims. Exact affected and fixed release boundaries cannot be confidently derived from the supplied version array; inspect stable commits and distribution backports.
Mitigation direction
Apply a vendor-supported kernel containing the referenced perf event state-check correction.
Consult the Linux distribution or appliance vendor for exact fixed package versions and backport status.
Prioritize multi-user systems where untrusted local users can access performance-monitoring facilities.
Use vendor-recommended access restrictions as temporary risk reduction if immediate kernel updating is unavailable.
Validation and detection
Record the running kernel version, architecture, distribution package release, and patch provenance.
Compare installed kernel sources or vendor changelogs with the two referenced stable corrections.
Confirm whether untrusted local users can access perf event functionality under current security policy.
After updating, verify the running kernel includes the correction and review logs for related UBSAN reports.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-787: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
2CVSS vectors
3Timeline events
1ADP providers
3Source links
SSVC decision data
CISA-ADPCISA Coordinator
Timestamp
Version
2.0.3
Exploitation: noneAutomatable: noTechnical Impact: total
CVSS vector scores
2 official scores
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-787 · source CWE mapping
Out-of-bounds Write
Out-of-bounds Write represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.