diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-20 11:39:03 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-21 21:07:36 -0400 |
commit | 3a531260a14631ae8d231279b8738884bf808e7b (patch) | |
tree | a44858fb4663a75dc385f899da87989952cd190f | |
parent | ef8ff74ed8dd9d4b3ba8cb9f2fc927a27c697a8b (diff) |
perf trace: Validate syscall id before growing syscall table
In some cases the ID for a syscall read thru the raw_syscalls tracepoint
is bogus, still needs to be investigated why, but to make the tool more
robust first try to resolve the ID to a name via libaudit and if it
fails, don't grow the table.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-0lsokw3xor7c4ijo45u6bauh@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-trace.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index dec8ced61fb0..83c6515e425d 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -56,6 +56,10 @@ static int trace__read_syscall_info(struct trace *trace, int id) | |||
56 | { | 56 | { |
57 | char tp_name[128]; | 57 | char tp_name[128]; |
58 | struct syscall *sc; | 58 | struct syscall *sc; |
59 | const char *name = audit_syscall_to_name(id, trace->audit_machine); | ||
60 | |||
61 | if (name == NULL) | ||
62 | return -1; | ||
59 | 63 | ||
60 | if (id > trace->syscalls.max) { | 64 | if (id > trace->syscalls.max) { |
61 | struct syscall *nsyscalls = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc)); | 65 | struct syscall *nsyscalls = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc)); |
@@ -75,11 +79,8 @@ static int trace__read_syscall_info(struct trace *trace, int id) | |||
75 | } | 79 | } |
76 | 80 | ||
77 | sc = trace->syscalls.table + id; | 81 | sc = trace->syscalls.table + id; |
78 | sc->name = audit_syscall_to_name(id, trace->audit_machine); | 82 | sc->name = name; |
79 | if (sc->name == NULL) | 83 | sc->fmt = syscall_fmt__find(sc->name); |
80 | return -1; | ||
81 | |||
82 | sc->fmt = syscall_fmt__find(sc->name); | ||
83 | 84 | ||
84 | snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->name); | 85 | snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->name); |
85 | sc->tp_format = event_format__new("syscalls", tp_name); | 86 | sc->tp_format = event_format__new("syscalls", tp_name); |