Skip to content

Commit

Permalink
perf trace: Validate syscall id before growing syscall table
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
acmel committed Oct 22, 2012
1 parent ef8ff74 commit 3a53126
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ static int trace__read_syscall_info(struct trace *trace, int id)
{
char tp_name[128];
struct syscall *sc;
const char *name = audit_syscall_to_name(id, trace->audit_machine);

if (name == NULL)
return -1;

if (id > trace->syscalls.max) {
struct syscall *nsyscalls = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc));
Expand All @@ -75,11 +79,8 @@ static int trace__read_syscall_info(struct trace *trace, int id)
}

sc = trace->syscalls.table + id;
sc->name = audit_syscall_to_name(id, trace->audit_machine);
if (sc->name == NULL)
return -1;

sc->fmt = syscall_fmt__find(sc->name);
sc->name = name;
sc->fmt = syscall_fmt__find(sc->name);

snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->name);
sc->tp_format = event_format__new("syscalls", tp_name);
Expand Down

0 comments on commit 3a53126

Please sign in to comment.