CVE-2025-37878: perf/core: Fix WARN_ON(!ctx) in __free_event() for partial init
In the Linux kernel, the following vulnerability has been resolved:
perf/core: Fix WARNON(!ctx) in freeevent() for partial init
Move the getctx(childctx) call and the childevent->ctx assignment to occur immediately after the child event is allocated. Ensure that childevent->ctx is non-NULL before any subsequent error path within inheritevent calls freeevent(), satisfying the assumptions of the cleanup code.
Details:
There's no clear Fixes tag, because this bug is a side-effect of multiple interacting commits over time (up to 15 years old), not a single regression.
The code initially incremented refcount then assigned context immediately after the childevent was created. Later, an early validity check for childevent was added before the refcount/assignment. Even later, a WARNONONCE() cleanup check was added, assuming event->ctx is valid if the pmuctx is valid. The problem is that the WARNONONCE() could trigger after the initial check passed but before childevent->ctx was assigned, violating its precondition. The solution is to assign childevent->ctx right after its initial validation. This ensures the context exists for any subsequent checks or cleanup routines, resolving the WARNONONCE().
To resolve it, defer the refcount update and childevent->ctx assignment directly after childevent->pmuctx is set but before checking if the parent event is orphaned. The cleanup routine depends on event->pmuctx being non-NULL before it verifies event->ctx is non-NULL. This also maintains the author's original intent of passing in childctx to findgetpmucontext before its refcount/assignment.
[ mingo: Expanded the changelog from another email by Gabriel Shahrouzi. ]
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 6.6.92.2-1
Event History
Frequently Asked Questions
What is the severity of CVE-2025-37878?
CVE-2025-37878 is categorized as a moderate severity vulnerability in the Linux kernel.
How do I fix CVE-2025-37878?
To fix CVE-2025-37878, update your Linux kernel to the latest patched version.
Which versions of Linux Kernel are affected by CVE-2025-37878?
CVE-2025-37878 affects specific versions of the Linux kernel that are vulnerable to the described issue.
What type of vulnerability is CVE-2025-37878?
CVE-2025-37878 is a kernel-level vulnerability specifically related to event management in the performance subsystem.
Is CVE-2025-37878 actively exploited?
As of now, there are no reports indicating that CVE-2025-37878 is being actively exploited in the wild.