linux/tools/perf
Ian Rogers d227b45fc1 perf machine: Add session back pointer to fix out of bounds read
thread__e_machine_endian() decides whether a thread is live, and so
whether to read /proc/pid/exe rather than fall back to the perf.data
environment, by recovering the session from the machine:

	session = container_of(machine->machines, struct perf_session,
			       machines);
	is_live = !session->data;

That only holds when the struct machines is the one embedded in a struct
perf_session. It is not the only one. aslr_tool keeps its own in struct
aslr_tool, and hists_cumulate, hists_filter, hists_link, hists_output
and thread-maps-share each put one on the stack. For those the
container_of subtracts offsetof(struct perf_session, machines) from an
address that was never inside a session, and the following load of
session->data reads outside the object, which is what ASan reports.

Replace the derivation with an explicit link. machines__init() takes the
owning session, or NULL when the machines is standalone, and
thread__e_machine_endian() reads it back through machines__session().

A NULL session is treated as live. The tests use synthetic pids that
have no /proc entry, so the read fails there and the e_machine falls
back to EM_HOST as before, rather than being decided by whatever the
out of bounds read happened to return. perf inject registers its
session with the aslr tool once the session exists, before any event is
processed, so that tool keeps reporting file based threads as not live.

Fixes: 70351029b5 ("perf thread: Add support for reading the e_machine type for a thread")
Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-25 14:08:40 +02:00
..
arch perf loongarch: Fix discarded const qualifier in _get_field() 2026-09-24 19:22:25 +02:00
bench perf bench messaging: Fix the formatting issue when printing. 2026-09-17 12:27:34 -03:00
check-header_ignore_hunks/lib
dlfilters
Documentation perf evsel: Improve callchain warning for s390 2026-09-25 00:55:44 +02:00
include/perf
jvmti
pmu-events perf jevents: Limit the number of JSON reading workers 2026-09-25 12:41:37 +02:00
python perf python: Fix ilist TreeNode string type drift 2026-09-13 18:39:12 -03:00
scripts tools: Port perf ui from GTK 2 to GTK 4 2026-09-09 17:00:04 -03:00
tests perf machine: Add session back pointer to fix out of bounds read 2026-09-25 14:08:40 +02:00
trace perf trace: Introduce kernel symbol beautifier for virtual addresses 2026-09-04 18:14:01 -03:00
ui perf annotate-data: Show the sample count in the data-type browser 2026-09-22 14:52:08 +02:00
util perf machine: Add session back pointer to fix out of bounds read 2026-09-25 14:08:40 +02:00
.clang-format perf tool: Align structs in arrays in .clang-format 2026-09-09 17:03:35 -03:00
.gitignore perf pmu-events: Split big_c_string storage into standalone compilation unit 2026-05-20 17:46:45 -03:00
bpf_skel.mak perf build: Compile BPF skeletons with -mcpu=v3 2026-06-04 10:58:32 -03:00
Build perf trace beauty: Make beauty generated C code standalone .o files 2026-05-20 17:46:45 -03:00
builtin-annotate.c perf annotate: Default to --itrace=i1i for data type profiling 2026-09-21 08:41:55 +02:00
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c perf buildid-list: Fix empty output for AUX data 2026-09-25 00:55:44 +02:00
builtin-c2c.c perf c2c: Print memory region data with stdio output 2026-09-24 19:33:20 +02:00
builtin-check.c perf data ctf: replace libbabeltrace with babeltrace2-ctf-writer 2026-06-04 17:34:52 -03:00
builtin-config.c perf tool: Tidy up util/cache.h header file users 2026-09-08 17:50:28 -03:00
builtin-daemon.c
builtin-data.c perf data ctf: replace libbabeltrace with babeltrace2-ctf-writer 2026-06-04 17:34:52 -03:00
builtin-diff.c perf tools: Guard test_bit from out-of-bounds sample CPU 2026-06-04 17:34:52 -03:00
builtin-evlist.c
builtin-ftrace.c perf ftrace latency: Do not read trace files when BPF is used 2026-09-08 18:04:33 -03:00
builtin-help.c perf tool: Tidy up util/cache.h header file users 2026-09-08 17:50:28 -03:00
builtin-inject.c perf machine: Add session back pointer to fix out of bounds read 2026-09-25 14:08:40 +02:00
builtin-kallsyms.c
builtin-kmem.c perf tools: Include file offset and event type name in skip messages 2026-06-03 16:31:03 -03:00
builtin-kvm.c perf hist: Remove keysym.h include from hist.h 2026-09-08 17:50:37 -03:00
builtin-kwork.c perf evlist: Add reference count checking 2026-06-30 10:17:11 -07:00
builtin-list.c perf list: Avoid repeated strlen() when escaping JSON strings 2026-09-13 18:44:37 -03:00
builtin-lock.c perf evlist: Add reference count checking 2026-06-30 10:17:11 -07:00
builtin-mem.c perf tool: Remove evsel from tool APIs that pass the sample 2026-05-20 16:34:23 -03:00
builtin-probe.c
builtin-record.c perf record: Fix unhandled POLLHUP on non_perf_event descriptors 2026-09-17 12:27:34 -03:00
builtin-report.c perf config: Add core.hybrid-merge to configure event merging 2026-09-18 17:37:45 -03:00
builtin-sched.c perf sched latency: Add histogram and time interval options 2026-08-07 10:56:23 -07:00
builtin-script.c perf tools: Show memory region in perf-script subcommand 2026-09-24 19:29:45 +02:00
builtin-stat.c perf stat: Avoid uninitialized memory read on error 2026-09-09 08:10:17 -03:00
builtin-timechart.c perf timechart: Fix memory leaks in draw_wakeups() 2026-06-30 17:04:51 -07:00
builtin-top.c perf config: Add core.hybrid-merge to configure event merging 2026-09-18 17:37:45 -03:00
builtin-trace.c perf trace: Free the whole evsel_trace in evsel__put_and_free_priv 2026-09-22 15:00:23 +02:00
builtin-version.c
builtin.h perf tool: Move usage strings and functions to perf.c 2026-09-08 17:50:32 -03:00
check-headers.sh
CREDITS
design.txt
Makefile perf tests: Improvements to build-test performance 2026-09-09 17:00:36 -03:00
Makefile.config perf build: Use the given CC rather than clang in clang builds 2026-09-22 14:45:33 +02:00
Makefile.perf perf build: Follow sourced files when running shellcheck 2026-09-25 00:55:45 +02:00
MANIFEST
perf-archive.sh
perf-completion.sh
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf tool: Add fallback stubs for missing dependencies 2026-09-08 17:50:34 -03:00
perf.h