Skip to content

Commit 848e7a0

Browse files
captain5050namhyung
authored andcommitted
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: Thomas Falcon <thomas.falcon@intel.com> Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: James Clark <james.clark@linaro.org> Link: https://lore.kernel.org/r/20250719030517.1990983-3-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 62f4512 commit 848e7a0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/perf/builtin-stat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ static struct aggr_cpu_id perf_stat__get_aggr(struct perf_stat_config *config,
13651365
struct aggr_cpu_id id;
13661366

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

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

0 commit comments

Comments
 (0)