linux/tools/perf/util
Wang Nan 1f121b03d0 perf tools: Deal with kernel module names in '[]' correctly
Before patch ba92732e98 ('perf kmaps: Check kmaps to make code more
robust'), 'perf report' and 'perf annotate' will segfault if trace data
contains kernel module information like this:

 # perf report -D -i ./perf.data
 ...
 0 0 0x188 [0x50]: PERF_RECORD_MMAP -1/0: [0xffffffbff1018000(0xf068000) @ 0]: x [test_module]
 ...

 # perf report -i ./perf.data --objdump=/path/to/objdump --kallsyms=/path/to/kallsyms

 perf: Segmentation fault
 -------- backtrace --------
 /path/to/perf[0x503478]
 /lib64/libc.so.6(+0x3545f)[0x7fb201f3745f]
 /path/to/perf[0x499b56]
 /path/to/perf(dso__load_kallsyms+0x13c)[0x49b56c]
 /path/to/perf(dso__load+0x72e)[0x49c21e]
 /path/to/perf(map__load+0x6e)[0x4ae9ee]
 /path/to/perf(thread__find_addr_map+0x24c)[0x47deec]
 /path/to/perf(perf_event__preprocess_sample+0x88)[0x47e238]
 /path/to/perf[0x43ad02]
 /path/to/perf[0x4b55bc]
 /path/to/perf(ordered_events__flush+0xca)[0x4b57ea]
 /path/to/perf[0x4b1a01]
 /path/to/perf(perf_session__process_events+0x3be)[0x4b428e]
 /path/to/perf(cmd_report+0xf11)[0x43bfc1]
 /path/to/perf[0x474702]
 /path/to/perf(main+0x5f5)[0x42de95]
 /lib64/libc.so.6(__libc_start_main+0xf4)[0x7fb201f23bd4]
 /path/to/perf[0x42dfc4]

This is because __kmod_path__parse treats '[' leading names as kernel
name instead of names of kernel module.

If perf.data contains build information and the buildid of such modules
can be found, the dso->kernel of it will be set to DSO_TYPE_KERNEL by
__event_process_build_id(), not kernel module.

It will then be passed to dso__load() -> dso__load_kernel_sym() ->
dso__load_kcore() if --kallsyms is provided.

The refered patch adds NULL pointer checker to avoid segfault. However,
such kernel modules are still processed incorrectly.

This patch fixes __kmod_path__parse, makes it treat names like
'[test_module]' as kernel modules.

kmod-path.c is also update to reflect the above changes.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1433321541-170245-1-git-send-email-wangnan0@huawei.com
[ Fixed the merged with 0443f36b0d ("perf machine: Fix the search
  for the kernel DSO on the unified list" ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-06-03 10:02:38 -03:00
..
include tools: Move tools/perf/util/include/linux/{list.h,poison.h} to tools/include 2015-06-02 19:07:29 -03:00
scripting-engines perf db-export: No need to have ->thread twice in struct export_sample 2015-04-02 13:18:43 -03:00
abspath.c
alias.c perf tools: Introduce zfree 2013-12-27 15:17:00 -03:00
annotate.c perf annotation: Add symbol__get_annotation 2015-05-27 20:30:56 -03:00
annotate.h perf tools: Fix segfault for symbol annotation on TUI 2015-01-16 17:49:29 -03:00
auxtrace.c perf tools: Add AUX area tracing Snapshot Mode 2015-05-05 18:13:00 -03:00
auxtrace.h perf record: Add AUX area tracing Snapshot Mode support 2015-05-05 18:13:01 -03:00
bitmap.c perf tools: Add bitmap_or function into bitmap object 2012-02-13 23:28:10 -02:00
Build perf tools: Move branch option parsing to own file 2015-05-27 21:02:17 -03:00
build-id.c perf machine: No need to have two DSOs lists 2015-05-29 12:43:43 -03:00
build-id.h perf buildid-cache: Add --purge FILE to remove all caches of FILE 2015-02-27 15:52:33 -03:00
cache.h perf report: Fix some option handling on --stdio 2015-05-14 10:05:22 -03:00
callchain.c perf tools: Enable LBR call stack support 2015-02-18 17:16:17 +01:00
callchain.h perf tools: Move TUI-specific fields out of map_symbol 2015-05-05 18:13:24 -03:00
cgroup.c perf cgroup: Use atomic.h for refcounting 2015-05-15 16:12:20 -03:00
cgroup.h perf cgroup: Use atomic.h for refcounting 2015-05-15 16:12:20 -03:00
cloexec.c perf tools: Work around lack of sched_getcpu in glibc < 2.6. 2015-03-24 12:08:07 -03:00
cloexec.h perf tools: Work around lack of sched_getcpu in glibc < 2.6. 2015-03-24 12:08:07 -03:00
color.c perf tools: Remove some unused functions from color.c 2015-01-21 13:24:32 -03:00
color.h perf tools: Remove some unused functions from color.c 2015-01-21 13:24:32 -03:00
comm.c perf comm: Use atomic.h for refcounting 2015-05-27 12:21:43 -03:00
comm.h perf tools: Add facility to export data in database-friendly way 2014-10-29 10:32:49 -02:00
config.c perf tools: Add --buildid-dir option to set cache directory 2014-12-09 09:14:35 -03:00
cpumap.c perf tools: Use cpu/possible instead of cpu/kernel_max 2014-04-22 17:39:16 +02:00
cpumap.h perf tools: Allow ability to map cpus to nodes easily 2014-04-22 17:39:12 +02:00
ctype.c perf tools: ctype.c only wants util.h 2012-02-13 23:17:40 -02:00
data-convert-bt.c perf data: Fix signedness of value 2015-04-29 10:37:49 -03:00
data-convert-bt.h perf data: Support using -f to override perf.data file ownership for 'convert' 2015-04-02 13:18:52 -03:00
data.c perf util: Replace strerror with strerror_r for thread-safety 2014-08-15 10:58:35 -03:00
data.h perf tools: Add perf_data_file__write interface 2013-12-02 09:22:46 -03:00
db-export.c perf db-export: Fix thread ref-counting 2015-05-29 12:43:39 -03:00
db-export.h perf db-export: No need to have ->thread twice in struct export_sample 2015-04-02 13:18:43 -03:00
debug.c perf data: Add perf data to CTF conversion support 2015-02-25 16:13:12 -03:00
debug.h perf data: Add perf data to CTF conversion support 2015-02-25 16:13:12 -03:00
dso.c perf tools: Deal with kernel module names in '[]' correctly 2015-06-03 10:02:38 -03:00
dso.h perf tools: Deal with kernel module names in '[]' correctly 2015-06-03 10:02:38 -03:00
dwarf-aux.c perf tools: Fix dwarf-aux.c compilation on i386 2015-05-15 16:59:43 -03:00
dwarf-aux.h perf probe: Ignore tail calls to probed functions 2015-05-14 10:05:09 -03:00
environment.c perf report: Fix some option handling on --stdio 2015-05-14 10:05:22 -03:00
event.c perf tools: Introduce struct maps 2015-05-27 20:21:41 -03:00
event.h perf machine: Protect the machine->threads with a rwlock 2015-05-08 16:19:27 -03:00
evlist.c perf evlist: Use atomic.h for the perf_mmap refcount 2015-05-15 15:45:16 -03:00
evlist.h perf tools: Elliminate alignment holes 2015-05-18 10:17:33 -03:00
evsel.c perf tools: Add hint for 'Too many events are opened.' error message 2015-05-27 20:28:37 -03:00
evsel.h perf tools: Elliminate alignment holes 2015-05-18 10:17:33 -03:00
exec_cmd.c perf tools: Makefile: Remove various and sundry cruft 2011-02-18 07:43:06 -02:00
exec_cmd.h
find-vdso-map.c perf tools: Build programs to copy 32-bit compatibility 2014-10-29 10:32:48 -02:00
generate-cmdlist.sh tools/perf: Standardize feature support define names to: HAVE_{FEATURE}_SUPPORT 2013-10-09 08:48:28 +02:00
header.c perf tools: Deal with kernel module names in '[]' correctly 2015-06-03 10:02:38 -03:00
header.h perf header: Add AUX area tracing feature 2015-04-29 10:37:49 -03:00
help.c perf tools: Use zfree to help detect use after free bugs 2013-12-27 17:08:19 -03:00
help.h
hist.c perf hists: Rename add_hist_entry to hists__findnew_entry 2015-05-27 12:21:43 -03:00
hist.h perf hists: Reducing arguments of hist_entry_iter__add() 2015-05-27 12:21:43 -03:00
intlist.c perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
intlist.h perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
kvm-stat.h perf kvm: Support using -f to override perf.data.guest file ownership 2015-04-02 13:18:47 -03:00
levenshtein.c
levenshtein.h
lzma.c perf tools: Add lzma decompression support for kernel module 2015-03-21 14:53:40 -03:00
machine.c perf tools: Deal with kernel module names in '[]' correctly 2015-06-03 10:02:38 -03:00
machine.h perf machine: Introduce machine__findnew_dso() method 2015-05-29 12:43:44 -03:00
map.c perf machine: Fix up vdso methods names 2015-05-29 12:43:44 -03:00
map.h perf tools: Reference count struct map 2015-05-27 20:27:30 -03:00
ordered-events.c perf ordered_samples: Remove references to perf_{evlist,tool} and machines 2015-03-31 17:52:32 -03:00
ordered-events.h perf ordered_samples: Remove references to perf_{evlist,tool} and machines 2015-03-31 17:52:32 -03:00
pager.c perf report: Fix some option handling on --stdio 2015-05-14 10:05:22 -03:00
parse-branch-options.c perf tools: Move branch option parsing to own file 2015-05-27 21:02:17 -03:00
parse-branch-options.h perf tools: Move branch option parsing to own file 2015-05-27 21:02:17 -03:00
parse-events.c perf tools: Fix parse_events_error dereferences 2015-05-27 12:21:43 -03:00
parse-events.h perf tools: Fix function declarations needed by parse-events.y 2015-05-27 12:21:43 -03:00
parse-events.l perf tools: Add term support for parse_events_error 2015-04-29 10:38:01 -03:00
parse-events.y perf tools: Fix parse_events_error dereferences 2015-05-27 12:21:43 -03:00
parse-options.c perf report: Don't allow empty argument for '-t'. 2015-03-19 13:53:28 -03:00
parse-options.h perf record: Add AUX area tracing Snapshot Mode support 2015-05-05 18:13:01 -03:00
path.c tools/perf: Turn strlcpy() into a __weak function 2013-10-09 08:48:49 +02:00
perf_regs.c perf tools: Cache register accesses for unwind processing 2014-06-12 16:53:19 +02:00
perf_regs.h perf tools: Cache register accesses for unwind processing 2014-06-12 16:53:19 +02:00
PERF-VERSION-GEN perf tools: Fix version when building out of tree 2013-11-07 10:40:47 -03:00
pmu.c perf tools: Remove newline char when reading event scale and unit 2015-06-01 10:26:19 -03:00
pmu.h perf tools: Add term support for parse_events_error 2015-04-29 10:38:01 -03:00
pmu.l perf tools: Add perf pmu object to access pmu format definition 2012-03-16 14:29:35 -03:00
pmu.y perf tools: Fix build with bison 2.3 and older. 2013-02-14 16:12:34 -03:00
probe-event.c perf probe: Fix segfault when glob matching function without debuginfo 2015-05-30 11:08:52 -03:00
probe-event.h perf probe: Show the error reason comes from invalid DSO 2015-05-27 12:21:45 -03:00
probe-finder.c perf probe: Ignore tail calls to probed functions 2015-05-14 10:05:09 -03:00
probe-finder.h perf probe: Introduce probe_conf global configs 2015-05-08 16:26:26 -03:00
pstack.c perf tools: Introduce pstack_peek() 2015-05-05 18:13:22 -03:00
pstack.h perf tools: Introduce pstack_peek() 2015-05-05 18:13:22 -03:00
python-ext-sources perf tools: Remove api fs object from python build 2015-02-12 11:22:01 -03:00
python.c perf tools: Remove EOL whitespaces 2015-01-21 13:24:31 -03:00
quote.c
quote.h
rblist.c perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
rblist.h perf util: Add findnew method to intlist 2013-10-14 10:28:48 -03:00
record.c perf tools: Add parse_events_error interface 2015-04-29 10:37:58 -03:00
run-command.c perf util: Replace strerror with strerror_r for thread-safety 2014-08-15 10:58:35 -03:00
run-command.h
session.c perf session: Fix perf_session__peek_event() 2015-05-27 12:21:43 -03:00
session.h perf tools: Add AUX area tracing index 2015-05-04 19:48:47 -03:00
setup.py tools lib api: Rename libapikfs.a to libapi.a 2015-02-12 17:55:18 -03:00
sigchain.c
sigchain.h
sort.c perf tools: Fix "Command" sort_entry's cmp and collapse function 2015-05-15 17:02:21 -03:00
sort.h perf tools: Move TUI-specific fields out of map_symbol 2015-05-05 18:13:24 -03:00
srcline.c perf: Fix building warning on ARM 32 2014-12-19 13:09:43 +01:00
stat.c perf stats: Add max and min stats 2013-08-07 17:35:26 -03:00
stat.h tools: Consolidate types.h 2014-05-01 21:22:39 +02:00
strbuf.c perf tools: Use zfree to help detect use after free bugs 2013-12-27 17:08:19 -03:00
strbuf.h
strfilter.c perf tools: Add strfilter__string to recover rules string 2015-05-04 12:43:54 -03:00
strfilter.h perf tools: Add strfilter__string to recover rules string 2015-05-04 12:43:54 -03:00
string.c Revert "perf tools: Default to cpu// for events v5" 2014-10-15 16:04:33 -03:00
strlist.c perf tools: Fix build error due to zfree() cast 2014-01-15 15:10:04 -03:00
strlist.h perf tools: Stop using 'self' in strlist 2013-01-25 12:49:28 -03:00
svghelper.c perf timechart: Implement IO mode 2014-07-10 00:22:54 +02:00
svghelper.h perf timechart: Implement IO mode 2014-07-10 00:22:54 +02:00
symbol-elf.c perf machine: No need to have two DSOs lists 2015-05-29 12:43:43 -03:00
symbol-minimal.c perf symbols: Save DSO loading errno to better report errors 2015-03-24 12:08:43 -03:00
symbol.c perf tools: Reference count struct map 2015-05-27 20:27:30 -03:00
symbol.h perf tools: Move TUI-specific fields out of map_symbol 2015-05-05 18:13:24 -03:00
target.c perf target: Simplify handling of strerror_r return 2015-03-24 12:08:30 -03:00
target.h perf target: Move the checking of which map function to call into function. 2013-12-04 13:46:37 -03:00
thread_map.c perf thread_map: Create dummy constructor out of open coded equivalent 2014-10-14 17:32:52 -03:00
thread_map.h perf thread_map: Create dummy constructor out of open coded equivalent 2014-10-14 17:32:52 -03:00
thread-stack.c perf tools: Enhance the thread stack to output call/return data 2014-11-03 17:43:56 -03:00
thread-stack.h perf tools: Enhance the thread stack to output call/return data 2014-11-03 17:43:56 -03:00
thread.c perf tools: Remove redundant initialization of thread linkage members 2015-05-27 12:21:44 -03:00
thread.h perf tools: Elliminate alignment holes 2015-05-18 10:17:33 -03:00
tool.h perf tools: Add support for PERF_RECORD_ITRACE_START 2015-05-05 18:12:58 -03:00
top.c perf tools: Rename 'perf_record_opts' to 'record_opts 2013-12-19 14:43:45 -03:00
top.h tools: Consolidate types.h 2014-05-01 21:22:39 +02:00
trace-event-info.c perf tools: Move pr_* debug macros into debug object 2014-07-17 12:58:39 -03:00
trace-event-parse.c perf tools: Assign default value for some pointers 2015-05-27 12:21:45 -03:00
trace-event-read.c perf tools: Remove needless getopt.h includes 2014-07-17 12:59:00 -03:00
trace-event-scripting.c perf scripting: No need to pass thread twice to the scripting callbacks 2015-04-02 13:18:41 -03:00
trace-event.c tools lib traceevent: Make plugin unload function receive pevent 2014-01-15 15:10:40 -03:00
trace-event.h perf scripting: No need to pass thread twice to the scripting callbacks 2015-04-02 13:18:41 -03:00
tsc.c perf tools: Move rdtsc() function 2014-07-23 11:48:11 -03:00
tsc.h perf tools: Move rdtsc() function 2014-07-23 11:48:11 -03:00
unwind-libdw.c perf callchains: Use thread->mg->machine 2014-10-29 10:32:46 -02:00
unwind-libdw.h perf tools: Add libdw DWARF post unwind support 2014-02-24 09:29:36 -03:00
unwind-libunwind.c perf tools: Add dso__data_get/put_fd() 2015-05-27 12:21:44 -03:00
unwind.h perf callchains: Use thread->mg->machine 2014-10-29 10:32:46 -02:00
usage.c perf target: Introduce perf_target__parse_uid() 2012-05-07 16:46:48 -03:00
util.c perf tools: Introduce copyfile_offset() function 2015-05-18 10:17:35 -03:00
util.h perf tools: Introduce copyfile_offset() function 2015-05-18 10:17:35 -03:00
values.c perf tools: Use zfree to help detect use after free bugs 2013-12-27 17:08:19 -03:00
values.h tools: Consolidate types.h 2014-05-01 21:22:39 +02:00
vdso.c perf machine: Fix up vdso methods names 2015-05-29 12:43:44 -03:00
vdso.h perf machine: Fix up vdso methods names 2015-05-29 12:43:44 -03:00
wrapper.c perf tools: Use __maybe_used for unused variables 2012-09-11 12:19:15 -03:00
xyarray.c perf tools: Introduce event selectors 2011-01-03 16:39:04 -02:00
xyarray.h perf tools: Introduce event selectors 2011-01-03 16:39:04 -02:00
zlib.c perf tools: Add gzip decompression support for kernel module 2014-11-05 10:11:26 -03:00