Re: [PATCH v2] perf cgroup: Update metric leader in evlist__expand_cgroup
From: Namhyung Kim
Date: Mon Apr 06 2026 - 13:49:44 EST
On Fri, 03 Apr 2026 23:05:52 -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.
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung