Re: [PATCH v2] perf cgroup: Update metric leader in evlist__expand_cgroup
From: Namhyung Kim
Date: Mon Apr 06 2026 - 13:52:35 EST
On Fri, Apr 03, 2026 at 11:05:52PM -0700, Ian Rogers wrote:
> When the evlist is expanded the metric leader wasn't being updated. As
> the original evsel is deleted this creates a use-after-free in
> stat-shadow's prepare_metric. This was detected running the "perf stat
> --bpf-counters --for-each-cgroup test" with sanitizers.
>
> The change itself puts the copied evsel into the priv field (known
> unused because of evsel__clone use) and then in a second pass over the
> list updates the copied values using the priv pointer.
>
> Fixes: d1c5a0e86a4e ("perf stat: Add --for-each-cgroup option")
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> Acked-by: Sun Jian <sun.jian.kdev@xxxxxxxxx>
Applied to perf-tools-next, thanks!
Best regards,
Namhyung