linux-stable/tools/perf/tests
Ian Rogers d975e59709 perf tests: Avoid raising SEGV using an obvious NULL dereference
[ Upstream commit e3e2cf3d5b ]

An optimized build such as:

  make -C tools/perf CLANG=1 CC=clang EXTRA_CFLAGS="-O3

will turn the dereference operation into a ud2 instruction, raising a
SIGILL rather than a SIGSEGV. Use raise(..) for correctness and clarity.

Similar issues were addressed in Numfor Mbiziwo-Tiapo's patch:

  https://lkml.org/lkml/2019/7/8/1234

Committer testing:

Before:

  [root@quaco ~]# perf test hooks
  55: perf hooks                                            : Ok
  [root@quaco ~]# perf test -v hooks
  55: perf hooks                                            :
  --- start ---
  test child forked, pid 17092
  SIGSEGV is observed as expected, try to recover.
  Fatal error (SEGFAULT) in perf hook 'test'
  test child finished with 0
  ---- end ----
  perf hooks: Ok
  [root@quaco ~]#

After:

  [root@quaco ~]# perf test hooks
  55: perf hooks                                            : Ok
  [root@quaco ~]# perf test -v hooks
  55: perf hooks                                            :
  --- start ---
  test child forked, pid 17909
  SIGSEGV is observed as expected, try to recover.
  Fatal error (SEGFAULT) in perf hook 'test'
  test child finished with 0
  ---- end ----
  perf hooks: Ok
  [root@quaco ~]#

Fixes: a074865e60 ("perf tools: Introduce perf hooks")
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lore.kernel.org/lkml/20190925195924.152834-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-11-06 13:05:41 +01:00
..
attr perf tools: Fix crash on synthesizing the unit 2018-12-17 09:24:31 +01:00
shell perf test vfs_getname: Disable ~/.perfconfig to get default output 2019-10-05 13:09:41 +02:00
.gitignore
attr.c perf tools: Fix snprint warnings for gcc 8 2018-03-19 10:00:43 -03:00
attr.py perf test: Fix perf_event_attr test failure 2019-02-12 19:47:11 +01:00
backward-ring-buffer.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
bitmap.c perf tools: Drop unneeded bitmap_zero() calls 2018-08-08 15:55:44 -03:00
bp_account.c perf tests bp_account: Fix build with clang-6 2018-03-19 13:51:54 -03:00
bp_signal.c perf tests ARM: Disable breakpoint tests 32-bit 2019-01-26 09:32:40 +01:00
bp_signal_overflow.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bpf-script-example.c perf test BPF: Fixup BPF test using epoll_pwait syscall function probe 2018-04-18 15:35:53 -03:00
bpf-script-test-kbuild.c perf tests bpf: Remove unused ptrace.h include from LLVM test 2018-04-12 10:33:24 -03:00
bpf-script-test-prologue.c perf bpf: Fix endianness problem when loading parameters in prologue 2017-08-16 10:31:11 -03:00
bpf-script-test-relocation.c
bpf.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
Build perf tests: Add mem2node object test 2018-03-16 13:52:48 -03:00
builtin-test.c perf tests: Fix indexing when invoking subtests 2018-07-31 10:52:51 -03:00
clang.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
code-reading.c perf tools: Get rid of dso__needs_decompress() call in read_object_code() 2018-08-20 08:54:59 -03:00
cpumap.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dso-data.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dwarf-unwind.c perf tests: Fix dwarf unwind for stripped binaries 2018-02-16 10:09:23 -03:00
event-times.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
event_update.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
evsel-roundtrip-name.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
evsel-tp-sched.c perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test() 2019-04-20 09:15:58 +02:00
expr.c perf tests: Fix memory leak by expr__find_other() in test__expr() 2019-04-20 09:15:58 +02:00
fdarray.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hists_common.c perf symbols: Unify symbol maps 2018-04-27 10:47:06 -03:00
hists_common.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hists_cumulate.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hists_filter.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hists_link.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hists_output.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
is_printable_array.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
keep-tracking.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
kmod-path.c perf tools: Remove ext from struct kmod_path 2018-08-20 08:54:59 -03:00
llvm.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
llvm.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
make Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild 2016-12-17 16:24:13 -08:00
mem.c perf tools: Fix snprint warnings for gcc 8 2018-03-19 10:00:43 -03:00
mem2node.c perf tools: Drop unneeded bitmap_zero() calls 2018-08-08 15:55:44 -03:00
mmap-basic.c perf tests mmap: Show which tracepoint is failing 2018-04-18 15:35:52 -03:00
mmap-thread-lookup.c perf test mmap-thread-lookup: Initialize variable to suppress memory sanitizer warning 2019-07-31 07:27:06 +02:00
openat-syscall-all-cpus.c perf tests: Fix a memory leak of cpu_map object in the openat_syscall_event_on_all_cpus test 2019-04-20 09:15:58 +02:00
openat-syscall-tp-fields.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
openat-syscall.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
parse-events.c perf test 6: Fix missing kvm module load for s390 2019-07-26 09:14:05 +02:00
parse-no-sample-id-all.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
perf-hooks.c perf tests: Avoid raising SEGV using an obvious NULL dereference 2019-11-06 13:05:41 +01:00
perf-record.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
perf-targz-src-pkg License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pmu.c perf tools: Fix snprint warnings for gcc 8 2018-03-19 10:00:43 -03:00
python-use.c perf test: Use header file util/debug.h 2018-06-04 10:28:53 -03:00
sample-parsing.c perf tools: Get rid of unused 'swapped' parameter from perf_event__synthesize_sample() 2018-01-18 09:01:23 -03:00
sdt.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
stat.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sw-clock.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
switch-tracking.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
task-exit.c perf mmap: Simplify perf_mmap__read_init() 2018-03-08 10:05:53 -03:00
tests.h perf tests: Add mem2node object test 2018-03-16 13:52:48 -03:00
thread-map.c perf thread_map: Enumerate all threads from /proc 2017-12-27 12:15:46 -03:00
thread-mg-share.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
topology.c perf test session topology: Fix test on s390 2018-06-25 11:59:35 -03:00
unit_number__scnprintf.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vmlinux-kallsyms.c perf machine: Ditch find_kernel_function variants 2018-04-30 12:20:54 -03:00