Commit 848e7a06 authored by Ian Rogers's avatar Ian Rogers Committed by Namhyung Kim
Browse files

perf stat: Avoid buffer overflow to the aggregation map



CPUs may be created and passed to perf_stat__get_aggr (via
config->aggr_get_id), such as in the stat display
should_skip_zero_counter. There may be no such aggr_id, for example,
if running with a thread. Add a missing bound check and just create
IDs for these cases.

Reviewed-by: default avatarThomas Falcon <thomas.falcon@intel.com>
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarJames Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250719030517.1990983-3-irogers@google.com


Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 62f45122
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1365,7 +1365,7 @@ static struct aggr_cpu_id perf_stat__get_aggr(struct perf_stat_config *config,
	struct aggr_cpu_id id;

	/* per-process mode - should use global aggr mode */
	if (cpu.cpu == -1)
	if (cpu.cpu == -1 || cpu.cpu >= config->cpus_aggr_map->nr)
		return get_id(config, cpu);

	if (aggr_cpu_id__is_empty(&config->cpus_aggr_map->map[cpu.cpu]))