From: "Mi, Dapeng" <dapeng1.mi@linux.intel.com>
To: Vinay Belgaumkar <vinay.belgaumkar@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Eranian Stephane <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Alexander Kanevskiy <alexander.kanevskiy@intel.com>
Subject: Re: [PATCH 1/2] perf: Fix null pointer access in is_include_guest_event()
Date: Mon, 7 Sep 2026 14:24:49 +0800 [thread overview]
Message-ID: <cf756325-e7a3-4e8e-8bb8-6b2b820e584c@linux.intel.com> (raw)
In-Reply-To: <20260904181625.1394082-1-vinay.belgaumkar@intel.com>
LGTM. Thanks.
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
On 9/5/2026 2:16 AM, Vinay Belgaumkar wrote:
> A typical module unload occurring event when there is an active perf
> connection leads to freeing of the pmu pointer. The call log is something
> like:
> ..
> __pmu_detach_event
> pmu_detach_event
> pmu_detach_events
> perf_pmu_unregister
> ..
>
> __pmu_detach_event() sets event->pmu to null. When the perf connection
> finally is closed, the following stack trace is observed:
>
> Oops: general protection fault, kernel NULL pointer dereference
> ...
> RIP: 0010:_free_event+0x3e/0x370
> ...
> Call Trace:
> ...
> perf_event_release_kernel+0x260/0x2d0
> perf_release+0x12/0x20
>
> A call to mediated_pmu_unaccount_event() inside _free_event() is the root
> cause of this crash. Adding a check inside is_include_guest_event() ensures
> we don't accidentally access a null pmu ptr. In addition to this, we will
> now call mediated_pmu_unaccount_event() before clearing the pmu ptr so that
> nr_include_guest_events counts are maintained correctly.
>
> Fixes: eff95e170275 ("perf: Add APIs to create/release mediated guest vPMUs")
> Cc: Alexander Kanevskiy <alexander.kanevskiy@intel.com>
> Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
> Assisted-by: Claude:Claude-Sonnet-5
> Signed-off-by: Vinay Belgaumkar <vinay.belgaumkar@intel.com>
> ---
> kernel/events/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index a6c8e38a3110..7777e82aad5e 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6350,6 +6350,9 @@ static DEFINE_MUTEX(perf_mediated_pmu_mutex);
> /* !exclude_guest event of PMU with PERF_PMU_CAP_MEDIATED_VPMU */
> static inline bool is_include_guest_event(struct perf_event *event)
> {
> + if (!event->pmu)
> + return false;
> +
> if ((event->pmu->capabilities & PERF_PMU_CAP_MEDIATED_VPMU) &&
> !event->attr.exclude_guest)
> return true;
> @@ -13002,6 +13005,7 @@ static void __pmu_detach_event(struct pmu *pmu, struct perf_event *event,
> exclusive_event_destroy(event);
> module_put(pmu->module);
>
> + mediated_pmu_unaccount_event(event);
> event->pmu = NULL; /* force fault instead of UAF */
> }
>
prev parent reply other threads:[~2026-09-07 6:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 18:16 [PATCH 1/2] perf: Fix null pointer access in is_include_guest_event() Vinay Belgaumkar
2026-09-04 18:16 ` [PATCH 2/2] perf: Add checks to prevent null ptr access Vinay Belgaumkar
2026-09-04 18:38 ` sashiko-bot
2026-09-04 18:49 ` [PATCH 1/2] perf: Fix null pointer access in is_include_guest_event() sashiko-bot
2026-09-07 6:24 ` Mi, Dapeng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cf756325-e7a3-4e8e-8bb8-6b2b820e584c@linux.intel.com \
--to=dapeng1.mi@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.kanevskiy@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=vinay.belgaumkar@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.