mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-11-10 20:48:12 +00:00
perf_iterate_sb() invokes its callback for each matching perf_event on
the CPU and task context, passing a shared caller-allocated event
structure.
perf_event_header__init_id() mutated header->size in place by adding
event->id_header_size, requiring sideband output callbacks to save and
restore header fields across iterations. Three sideband callbacks failed
to save and restore header.size around perf_event_header__init_id():
- perf_event_ksymbol_output()
- perf_event_bpf_output()
- perf_event_text_poke_output()
When multiple events with attr.ksymbol, attr.bpf_event, or
attr.text_poke and sample_id_all are active on the same CPU, each
subsequent event receives a record whose header.size is inflated by all
preceding events' id_header_size values while only a single id_sample is
written, leaving uninitialized ring-buffer bytes at the end of the
record and causing userspace perf to fail with -EFAULT ("Bad address")
when parsing the sample_id trailer.
Similarly, perf_event_mmap_output() set PERF_RECORD_MISC_MMAP_BUILD_ID
in mmap_event->event_id.header.misc when event->attr.build_id was
enabled, but only saved and restored header.size and header.type. If an
event with attr.build_id was followed by an event with attr.mmap2 and
!attr.build_id, the second event received PERF_RECORD_MISC_MMAP_BUILD_ID
in header.misc while its payload contained maj/min/ino/ino_generation
instead of a build ID.
Rather than splitting header initialization between callers and output
callbacks and saving/restoring mutated header fields, replace
perf_event_header__init_id() with perf_event_header__init(), which
initializes header->type, header->misc, and header->size alongside the
sample_id fields on each invocation.
Fixes:
|
History
|
|
|---|---|---|
| .. | ||
| req-gen | ||
| 8xx-pmu.c | ||
| bhrb.S | ||
| callchain.c | ||
| callchain.h | ||
| callchain_32.c | ||
| callchain_64.c | ||
| core-book3s.c | ||
| core-fsl-emb.c | ||
| e500-pmu.c | ||
| e6500-pmu.c | ||
| generic-compat-pmu.c | ||
| hv-24x7-catalog.h | ||
| hv-24x7-domains.h | ||
| hv-24x7.c | ||
| hv-24x7.h | ||
| hv-common.c | ||
| hv-common.h | ||
| hv-gpci-requests.h | ||
| hv-gpci.c | ||
| hv-gpci.h | ||
| imc-pmu.c | ||
| internal.h | ||
| isa207-common.c | ||
| isa207-common.h | ||
| kvm-hv-pmu.c | ||
| Makefile | ||
| mpc7450-pmu.c | ||
| perf_regs.c | ||
| power5+-pmu.c | ||
| power5-pmu.c | ||
| power6-pmu.c | ||
| power7-events-list.h | ||
| power7-pmu.c | ||
| power8-events-list.h | ||
| power8-pmu.c | ||
| power9-events-list.h | ||
| power9-pmu.c | ||
| power10-events-list.h | ||
| power10-pmu.c | ||
| power12-events-list.h | ||
| power12-pmu.c | ||
| ppc970-pmu.c | ||
| vpa-dtl.c | ||
| vpa-pmu.c | ||