linux-stable/tools/perf
Casey Chen 1b46b23561 perf tool: fix dereferencing NULL al->maps
[ Upstream commit 4c17736689 ]

With 0dd5041c9a ("perf addr_location: Add init/exit/copy functions"),
when cpumode is 3 (macro PERF_RECORD_MISC_HYPERVISOR),
thread__find_map() could return with al->maps being NULL.

The path below could add a callchain_cursor_node with NULL ms.maps.

add_callchain_ip()
  thread__find_symbol(.., &al)
    thread__find_map(.., &al)   // al->maps becomes NULL
  ms.maps = maps__get(al.maps)
  callchain_cursor_append(..., &ms, ...)
    node->ms.maps = maps__get(ms->maps)

Then the path below would dereference NULL maps and get segfault.

fill_callchain_info()
  maps__machine(node->ms.maps);

Fix it by checking if maps is NULL in fill_callchain_info().

Fixes: 0dd5041c9a ("perf addr_location: Add init/exit/copy functions")
Signed-off-by: Casey Chen <cachen@purestorage.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: yzhong@purestorage.com
Link: https://lore.kernel.org/r/20240722211548.61455-1-cachen@purestorage.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-11 12:47:18 +02:00
..
arch perf intel-pt: Fix exclude_guest setting 2024-08-03 08:53:53 +02:00
bench perf bench internals inject-build-id: Fix trap divide when collecting just one DSO 2024-06-12 11:12:26 +02:00
dlfilters perf dlfilter: Add a test for object_code() 2023-09-30 00:09:06 -07:00
Documentation perf: script: add raw|disasm arguments to --insn-trace option 2024-06-27 13:49:14 +02:00
include/perf perf dlfilter: Add al_cleanup() 2023-08-15 16:41:49 -03:00
jvmti
pmu-events perf stat: Do not fail on metrics on s390 z/VM systems 2024-06-12 11:12:15 +02:00
python
scripts perf scripts python gecko: Launch the profiler UI on the default browser with the appropriate URL 2023-08-24 14:41:49 -03:00
tests perf test: Make test_arm_callgraph_fp.sh more robust 2024-08-03 08:53:52 +02:00
trace perf tools changes for v6.6: 2023-09-09 20:06:17 -07:00
ui perf ui browser: Avoid SEGV on title 2024-06-12 11:12:28 +02:00
util perf tool: fix dereferencing NULL al->maps 2024-08-11 12:47:18 +02:00
.gitignore
Build
builtin-annotate.c perf annotate: Use global annotation_options 2024-06-12 11:12:16 +02:00
builtin-bench.c perf tools changes for v6.6: 2023-09-09 20:06:17 -07:00
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c
builtin-config.c
builtin-daemon.c perf daemon: Fix file leak in daemon_session__control 2024-06-12 11:12:30 +02:00
builtin-data.c
builtin-diff.c perf diff: Replaces some ',' as separator with the more usual ';' 2023-07-20 11:43:45 -03:00
builtin-evlist.c
builtin-ftrace.c
builtin-help.c
builtin-inject.c perf record: Lazy load kernel symbols 2024-06-12 11:12:15 +02:00
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c
builtin-kwork.c perf kwork: Set ordered_events to true in 'struct perf_tool' 2023-11-20 11:59:25 +01:00
builtin-list.c perf list: Fix JSON segfault by setting the used skip_duplicate_pmus callback 2023-12-13 18:45:34 +01:00
builtin-lock.c tools/perf: Update call stack check in builtin-lock.c 2023-11-20 11:59:26 +01:00
builtin-mem.c
builtin-probe.c
builtin-record.c perf record: Fix debug message placement for test consumption 2024-06-12 11:12:18 +02:00
builtin-report.c perf report: Avoid SEGV in report__setup_sample_type() 2024-06-12 11:12:28 +02:00
builtin-sched.c perf sched timehist: Fix -g/--call-graph option failure 2024-06-12 11:13:02 +02:00
builtin-script.c perf script: Show also errors for --insn-trace option 2024-06-27 13:49:14 +02:00
builtin-stat.c perf stat: Exit perf stat if parse groups fails 2024-01-25 15:35:51 -08:00
builtin-timechart.c
builtin-top.c perf annotate: Use global annotation_options 2024-06-12 11:12:16 +02:00
builtin-trace.c perf trace: Use heuristic when deciding if a syscall tracepoint "const char *" field is really a string 2023-08-18 16:33:28 -03:00
builtin-version.c
builtin.h
check-headers.sh tools headers UAPI: Copy seccomp.h to be able to build 'perf bench' in older systems 2023-09-13 08:48:48 -03:00
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config perf parse-events: Remove BPF event support 2023-08-15 16:41:48 -03:00
Makefile.perf perf bpf: Clean up the generated/copied vmlinux.h 2024-03-26 18:19:45 -04:00
MANIFEST
perf-archive.sh
perf-completion.sh
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf parse-events: Remove BPF event support 2023-08-15 16:41:48 -03:00
perf.h