linux-stable/tools/perf
Tiezhu Yang 300a55a3a6 perf top: Skip side-band event setup if HAVE_LIBBPF_SUPPORT is not set
commit 0c5f1acc2a upstream.

When I execute 'perf top' without HAVE_LIBBPF_SUPPORT, there exists the
following segmentation fault, skip the side-band event setup to fix it,
this is similar with commit 1101c872c8 ("perf record: Skip side-band
event setup if HAVE_LIBBPF_SUPPORT is not set").

  [yangtiezhu@linux perf]$ ./perf top
  <SNIP>
  perf: Segmentation fault
  Obtained 6 stack frames.
  ./perf(sighandler_dump_stack+0x5c) [0x12011b604]
  [0xffffffc010]
  ./perf(perf_mmap__read_init+0x3e) [0x1201feeae]
  ./perf() [0x1200d715c]
  /lib64/libpthread.so.0(+0xab9c) [0xffee10ab9c]
  /lib64/libc.so.6(+0x128f4c) [0xffedc08f4c]
  Segmentation fault
  [yangtiezhu@linux perf]$

I use git bisect to find commit b38d85ef49 ("perf bpf: Decouple
creating the evlist from adding the SB event") is the first bad commit,
so also add the Fixes tag.

Committer testing:

First build perf explicitely disabling libbpf:

  $ make NO_LIBBPF=1 O=/tmp/build/perf -C tools/perf install-bin && perf test python

Now make sure it isn't linked:

  $ perf -vv | grep -w bpf
                   bpf: [ OFF ]  # HAVE_LIBBPF_SUPPORT
  $
  $ nm ~/bin/perf | grep libbpf
  $

And now try to run 'perf top':

  # perf top
  perf: Segmentation fault
  -------- backtrace --------
  perf[0x5bcd6d]
  /lib64/libc.so.6(+0x3ca6f)[0x7fd0f5a66a6f]
  perf(perf_mmap__read_init+0x1e)[0x5e1afe]
  perf[0x4cc468]
  /lib64/libpthread.so.0(+0x9431)[0x7fd0f645a431]
  /lib64/libc.so.6(clone+0x42)[0x7fd0f5b2b912]
  #

Applying this patch fixes the issue.

Fixes: b38d85ef49 ("perf bpf: Decouple creating the evlist from adding the SB event")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xuefeng Li <lixuefeng@loongson.cn>
Link: http://lore.kernel.org/lkml/1597753837-16222-1-git-send-email-yangtiezhu@loongson.cn
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-01-25 14:34:33 -08:00
..
arch perf tools: Fix record failure when mixed with ARM SPE event 2020-08-05 09:59:49 +02:00
bench parisc: Align parisc MADV_XXX constants with all other architectures 2023-01-18 11:42:00 +01:00
Documentation perf record/stat: Explicitly call out event modifiers in the documentation 2020-09-05 11:22:49 +02:00
examples/bpf
include/bpf
jvmti
lib
pmu-events perf jevents: Make build dependency on test JSONs 2023-09-23 11:00:05 +02:00
python tweewide: Fix most Shebang lines 2021-05-22 11:38:30 +02:00
scripts perf scripts python: exported-sql-viewer.py: Fix warning display 2021-06-03 08:59:00 +02:00
tests perf test uprobe_from_different_cu: Skip if there is no gcc 2023-08-11 11:53:55 +02:00
trace perf trace: Add the syscall_arg_fmt pointer to syscall_arg 2023-01-18 11:41:28 +01:00
ui perf hists browser: Fix hierarchy mode header 2023-09-23 11:00:00 +02:00
util perf env: Avoid recursively taking env->bpf_progs.lock 2024-01-25 14:34:31 -08:00
.gitignore
Build
builtin-annotate.c
builtin-bench.c
builtin-buildid-cache.c
builtin-buildid-list.c
builtin-c2c.c perf c2c: Fix sorting in percent_rmt_hitm_cmp() 2022-06-14 18:11:56 +02:00
builtin-config.c
builtin-data.c
builtin-diff.c
builtin-evlist.c
builtin-ftrace.c perf ftrace: Fix access to pid in array when setting a pid filter 2021-05-07 10:51:37 +02:00
builtin-help.c
builtin-inject.c perf inject: Close inject.output on exit 2021-07-28 13:31:02 +02:00
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c
builtin-list.c
builtin-lock.c perf lock: Don't free "lock_seq_stat" if read_count isn't zero 2020-11-24 13:29:05 +01:00
builtin-mem.c
builtin-probe.c perf probe: Do not show the skipped events 2020-06-22 09:31:27 +02:00
builtin-record.c perf bpf: Decouple creating the evlist from adding the SB event 2024-01-25 14:34:31 -08:00
builtin-report.c perf report: Fix memory leaks around perf_tip() 2021-12-08 09:01:10 +01:00
builtin-sched.c perf sched: Cast PTHREAD_STACK_MIN to int as it may turn into sysconf(__SC_THREAD_STACK_MIN_VALUE) 2023-05-17 11:35:32 +02:00
builtin-script.c perf script: Fix CPU filtering of a script's switch events 2022-01-05 12:37:46 +01:00
builtin-stat.c perf stat: Skip duration_time in setup_system_wide 2020-10-29 09:57:50 +01:00
builtin-timechart.c
builtin-top.c perf top: Skip side-band event setup if HAVE_LIBBPF_SUPPORT is not set 2024-01-25 14:34:33 -08:00
builtin-trace.c perf trace: Handle failure when trace point folder is missed 2023-01-18 11:41:28 +01:00
builtin-version.c
builtin.h
check-headers.sh x86: xen: insn: Decode Xen and KVM emulate-prefix signature 2022-05-15 19:54:47 +02:00
command-list.txt
CREDITS
design.txt
Makefile
Makefile.config perf tools: Add an option to build without libbfd 2023-09-23 11:00:05 +02:00
Makefile.perf tools: Factor HOSTCC, HOSTLD, HOSTAR definitions 2021-01-30 13:54:10 +01:00
MANIFEST
perf-archive.sh
perf-completion.sh perf tools: Fix auto-complete on aarch64 2023-03-11 16:43:49 +01:00
perf-read-vdso.c
perf-sys.h
perf-with-kcore.sh
perf.c perf tools: Fix perf's libperf_print callback 2022-04-15 14:18:38 +02:00
perf.h