diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-06-04 18:23:35 -0300 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-06-05 17:19:31 -0300 |
| commit | 06e7994427ab56e32699a5e45d048ff0826f3d53 (patch) | |
| tree | 05d6af04d6db315cadfc96b0b2b82ff60ed7191f /tools/perf/scripts/python/stackcollapse.py | |
| parent | fa20c1f8f4e094abe0169d39fce8181bc26d6dab (diff) | |
perf sched: Cap max_cpu at MAX_CPUS in timehist sample processing
perf_timehist__process_sample() updates sched->max_cpu from the
sample CPU without bounds checking. Later code uses max_cpu + 1 as
an iteration count over arrays allocated with MAX_CPUS entries
(curr_thread, cpu_last_switched). A recording with CPU IDs >= MAX_CPUS
causes out-of-bounds array accesses.
Also cap the env->nr_cpus_online initialization of max_cpu in
perf_sched__timehist(), which could exceed MAX_CPUS on very large
systems.
Add bounds checks before both max_cpu updates, matching the pattern
already used in map_switch_event().
Fixes: 49394a2a24c7 ("perf sched timehist: Introduce timehist command")
Reviewed-by: David Ahern <dsahern@kernel.org>
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
