summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/bin
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2026-11-01 19:05:10 +0000
committerAlexei Starovoitov <ast@kernel.org>2026-11-02 00:10:39 +0000
commita08ba2ab79dffd92c32d3f2dadfc7eba03625a2b (patch)
treebfbd13eb8a70387aa3cf18f78b2a20896e37df45 /tools/perf/scripts/python/bin
parent007fd460798be9af7d4874734f934afa47742f29 (diff)
bpf: Clamp the trace length before the skip test in stackid_init()
stackid_init() gives a bucket of the stack map min(trace_nr - skip, max_depth - skip) trace entries. Here max_depth is the size of a bucket plus skip, but at most perf_event_max_stack. Context markers can make trace_nr larger than that, so the skip test can pass when max_depth < skip. Then 'max_depth - skip' wraps, and the kernel can write after the bucket. Clamp trace_nr to max_depth before the skip test, as __bpf_get_stack_pe() does. The result changes only when skip >= max_depth. Then it is -EFAULT. Until now skip == max_depth could give the id of an empty trace. get_perf_callchain() releases the trace, so an NMI can change trace->nr. Use READ_ONCE() in bpf_get_stackid(), so the compiler reads it one time. Fixes: 23f852daa4ba ("bpf: Fix stackmap overflow check in __bpf_get_stackid()") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261101190535.1454146-3-alexei.starovoitov@gmail.com
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions