Revision 3f938ee2f6c4fff8d95b24636a0964b5a93cf547 authored by Jiri Olsa on 26 June 2017, 09:51:53 UTC, committed by Arnaldo Carvalho de Melo on 26 June 2017, 14:52:37 UTC
Michael reported the segfault when kernel.kptr_restrict=2 is set.

  $ perf record ls
  ...
  perf: Segmentation fault
  Obtained 16 stack frames.
  ./perf(dump_stack+0x2d) [0x5068df]
  ./perf(sighandler_dump_stack+0x2d) [0x5069bf]
  ./perf() [0x43e47b]
  /lib64/libc.so.6(+0x3594f) [0x7f762004794f]
  /lib64/libc.so.6(strlen+0x26) [0x7f762009ef86]
  /lib64/libc.so.6(__strdup+0xd) [0x7f762009ecbd]
  ./perf(maps__set_kallsyms_ref_reloc_sym+0x4d) [0x51590f]
  ./perf(machine__create_kernel_maps+0x136) [0x50a7de]
  ./perf(perf_session__create_kernel_maps+0x2c) [0x510a81]
  ./perf(perf_session__new+0x13d) [0x510e23]
  ./perf() [0x43fd61]
  ./perf(cmd_record+0x704) [0x441823]
  ./perf() [0x4bc1a0]
  ./perf() [0x4bc40d]
  ./perf() [0x4bc55f]
  ./perf(main+0x2d5) [0x4bc939]
  Segmentation fault (core dumped)

The reason is that with kernel.kptr_restrict=2, we don't get
the symbol from machine__get_running_kernel_start, which we
want to use in maps__set_kallsyms_ref_reloc_sym and we crash.

Check the symbol name value before calling
maps__set_kallsyms_ref_reloc_sym() and succeed without ref_reloc_sym
being set. It's safe because we check its existence before we use it.

Reported-by: Michael Petlan <mpetlan@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20170626095153.553-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 977282e
History
File Mode Size
platform
acbuffer.h -rw-r--r-- 10.4 KB
acconfig.h -rw-r--r-- 8.7 KB
acexcep.h -rw-r--r-- 17.2 KB
acnames.h -rw-r--r-- 3.7 KB
acoutput.h -rw-r--r-- 17.7 KB
acpi.h -rw-r--r-- 3.1 KB
acpi_bus.h -rw-r--r-- 18.2 KB
acpi_drivers.h -rw-r--r-- 4.0 KB
acpi_io.h -rw-r--r-- 674 bytes
acpi_lpat.h -rw-r--r-- 1.5 KB
acpi_numa.h -rw-r--r-- 560 bytes
acpiosxf.h -rw-r--r-- 12.3 KB
acpixf.h -rw-r--r-- 31.4 KB
acrestyp.h -rw-r--r-- 17.6 KB
actbl.h -rw-r--r-- 20.0 KB
actbl1.h -rw-r--r-- 34.4 KB
actbl2.h -rw-r--r-- 40.6 KB
actbl3.h -rw-r--r-- 19.8 KB
actypes.h -rw-r--r-- 41.8 KB
acuuid.h -rw-r--r-- 4.0 KB
apei.h -rw-r--r-- 1.3 KB
button.h -rw-r--r-- 582 bytes
cppc_acpi.h -rw-r--r-- 2.9 KB
ghes.h -rw-r--r-- 1.5 KB
hed.h -rw-r--r-- 371 bytes
pcc.h -rw-r--r-- 786 bytes
pdc_intel.h -rw-r--r-- 1009 bytes
processor.h -rw-r--r-- 10.9 KB
reboot.h -rw-r--r-- 162 bytes
video.h -rw-r--r-- 2.8 KB

back to top