[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1435333501-3429-2-git-send-email-acme@kernel.org>
Date: Fri, 26 Jun 2015 12:44:38 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: linux-kernel@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Borislav Petkov <bp@...e.de>, David Ahern <dsahern@...il.com>,
Don Zickus <dzickus@...hat.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>
Subject: [PATCH 01/24] perf trace: Validate syscall list passed via -e argument
From: Arnaldo Carvalho de Melo <acme@...hat.com>
The 'trace' tool was accepting any names passed and just looking if
syscalls returned via the raw_syscalls:* tracepoints were in that list,
leading to it accepting perf events and then never finding any, as those
are not valid syscall names, confusing users.
Fix it by checking each entry in the list using audit_name_to_syscall,
telling the user which entries are invalid and suggesting where to look
for valid syscall names.
E.g:
[root@zoo ~]# trace -e open,foo,bar,close,baz
Error: Invalid syscall bar, baz, foo
Hint: try 'perf list syscalls:sys_enter_*'
Hint: and: 'man syscalls'
[root@zoo ~]#
Reported-by: Flavio Leitner <fbl@...hat.com>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Borislav Petkov <bp@...e.de>
Cc: David Ahern <dsahern@...il.com>
Cc: Don Zickus <dzickus@...hat.com>
Cc: Frederic Weisbecker <fweisbec@...il.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Link: http://lkml.kernel.org/n/tip-4g1i3m1z6fzsrznn2umi02wa@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/builtin-trace.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 2bf2ca771ca5..39ad4d0ca884 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1617,6 +1617,34 @@ static int trace__read_syscall_info(struct trace *trace, int id)
return syscall__set_arg_fmts(sc);
}
+static int trace__validate_ev_qualifier(struct trace *trace)
+{
+ int err = 0;
+ struct str_node *pos;
+
+ strlist__for_each(pos, trace->ev_qualifier) {
+ const char *sc = pos->s;
+
+ if (audit_name_to_syscall(sc, trace->audit.machine) < 0) {
+ if (err == 0) {
+ fputs("Error:\tInvalid syscall ", trace->output);
+ err = -EINVAL;
+ } else {
+ fputs(", ", trace->output);
+ }
+
+ fputs(sc, trace->output);
+ }
+ }
+
+ if (err < 0) {
+ fputs("\nHint:\ttry 'perf list syscalls:sys_enter_*'"
+ "\nHint:\tand: 'man syscalls'\n", trace->output);
+ }
+
+ return err;
+}
+
/*
* args is to be interpreted as a series of longs but we need to handle
* 8-byte unaligned accesses. args points to raw_data within the event
@@ -2862,6 +2890,10 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
err = -ENOMEM;
goto out_close;
}
+
+ err = trace__validate_ev_qualifier(&trace);
+ if (err)
+ goto out_close;
}
err = target__validate(&trace.opts.target);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists