diff options
| author | Usama Arif <usama.arif@linux.dev> | 2026-11-19 13:10:44 -0800 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2026-11-23 10:37:47 +0100 |
| commit | b57e800b6e70a0957642ab2bf1db3e176ac229b5 (patch) | |
| tree | 01728e41a648d872cb61eeb4bfb30695763d44ce /tools/lib/python | |
| parent | 4aa81df6bb45e9cf693c86849fe90d4e3dd85bbc (diff) | |
perf/core: Fix perf_sample_data reuse across software events
do_perf_sw_event() passes one on-stack struct perf_sample_data to every
matching event. perf_prepare_sample() fills in the fields an event
samples, marks them in data->sample_flags and skips fields that are
already marked, and those marks survive from one event to the next.
So a sampling event later in the list emits the sample ID, timestamp,
pid/tid and callchain prepared for an earlier one. Its record size is
computed from the earlier event's dynamic fields as well and can come
out smaller than what is written, in which case the kernel writes past
its ring-buffer reservation over the records that follow.
Two "perf record -e page-faults,context-switches -c 1 -a" sessions
running at the same time hit this: the one started first gets the
other's sample IDs and fails with "Bad address".
Commit:
1d1bfe30dad5 ("perf/core: Fix perf_sample_data not properly initialized for different swevents in perf_tp_event()")
fixed the same problem for tracepoints. Do the same here: initialize
the struct for each matching event. While at it, drop the unused 'data'
argument of perf_swevent_match().
Fixes: bb447c27a467 ("perf/core: Set data->sample_flags in perf_prepare_sample()")
Signed-off-by: Usama Arif <usama.arif@linux.dev>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261119211235.99805-2-usama.arif@linux.dev
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
