diff options
| author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-06-04 12:55:06 -0300 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-06-04 17:34:52 -0300 |
| commit | a5498ccf8079fc91c938f122ff9697b0c526b2fd (patch) | |
| tree | 9fcb61a524f8ea44aed71df980642dda442ee1a4 /tools/perf/scripts/python/stackcollapse.py | |
| parent | 824b18f607d82503a956d3e00f9e9c0b24efcbca (diff) | |
perf tools: Guard test_bit from out-of-bounds sample CPU
When PERF_SAMPLE_CPU is absent from a perf.data file, sample->cpu is
initialized to (u32)-1 by evsel__parse_sample(). Five call sites pass
this value directly to test_bit(sample->cpu, cpu_bitmap), reading
massively out of bounds past the DECLARE_BITMAP(..., MAX_NR_CPUS)
allocation of 4096 bits.
Add a sample->cpu >= MAX_NR_CPUS guard before each test_bit() call,
matching the existing safe pattern in builtin-kwork.c. This catches
both the (u32)-1 sentinel and any corrupted CPU value exceeding the
bitmap size.
Fixes: 5d67be97f890 ("perf report/annotate/script: Add option to specify a CPU range")
Cc: Anton Blanchard <anton@samba.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
