From: sashiko-bot@kernel.org
To: "Daniel Wade" <danjwade95@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf: Don't read the original event's pmu_ctx in inherit_event()
Date: Mon, 16 Nov 2026 13:19:44 +0000 [thread overview]
Message-ID: <sashiko-outbox-217059@kernel.org> (raw)
In-Reply-To: <20261116130736.32585-1-danjwade95@gmail.com>
> inherit_event() walks @parent_event up to the original, top-level event
> and takes the PMU from its pmu_ctx. perf_event_init_context() holds the
> mutex of the forking task's own context, but that original is attached to
> the context it was opened in, whose mutex and lock are both unheld, and the
> fork is not in an RCU read-side section. The move_group path of
> perf_event_open() drops that pmu_ctx with put_pmu_ctx(), which can free it
> through call_rcu(), and reinstalls the pointer only two loops later:
>
> G: perf_event_open(group_fd = P) M, a child of G: fork()
> -------------------------------- ----------------------------
> put_pmu_ctx(P->pmu_ctx)
> call_rcu(free_epc_rcu)
> [ grace period -> kfree() ] inherit_event(C)
> parent_event = P
> P->pmu_ctx->pmu <-- freed
> P->pmu_ctx = pmu_ctx
>
> The value is used as a struct pmu. No privilege is needed: a software
> leader, an inheriting hardware event on the caller's own task, and a fork.
>
> Take the PMU from the event inherit_event() is given, before the
> replacement; it is attached to @parent_ctx, whose mutex is held. The result
> differs only when the group was moved after the context was cloned from it.
>
> Fixes: 4b9ce6719606 ("perf: Make sure to use pmu_ctx->pmu for groups")
> Signed-off-by: Daniel Wade <danjwade95@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116130736.32585-1-danjwade95@gmail.com?part=1
prev parent reply other threads:[~2026-11-16 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 13:07 [PATCH] perf: Don't read the original event's pmu_ctx in inherit_event() Daniel Wade
2026-11-16 13:19 ` sashiko-bot [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=sashiko-outbox-217059@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=danjwade95@gmail.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox