lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1456390315-127562-3-git-send-email-wangnan0@huawei.com>
Date:	Thu, 25 Feb 2016 08:51:52 +0000
From:	Wang Nan <wangnan0@...wei.com>
To:	<acme@...nel.org>, <jolsa@...nel.org>
CC:	<linux-kernel@...r.kernel.org>, Wang Nan <wangnan0@...wei.com>,
	"Arnaldo Carvalho de Melo" <acme@...hat.com>,
	Li Zefan <lizefan@...wei.com>, <pi3orama@....com>
Subject: [RFC PATCH 2/5] perf trace: Improve error message when receive non-tracepoint events

Before this patch, strange error message is provided if passed a
non-tracepoint event to 'perf trace':

 # perf trace -a  --ev cycles sleep 1
 Failed to set filter "common_pid != 27500" on event cycles with 22 (Invalid argument)

This is because 'perf trace' accepts all valid event during cmdline
parsing, but since it need setting filter to events, actually user
can pass tracepoints with '--ev' only.

This patch validate evlist, report error earlier:

 # ./perf trace -a  --ev cycles sleep 1
 Only support tracepoint events!

Signed-off-by: Wang Nan <wangnan0@...wei.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Li Zefan <lizefan@...wei.com>
Cc: pi3orama@....com
---
 tools/perf/builtin-trace.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 6c52f3c..2deb3f0 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -2525,6 +2525,17 @@ out_enomem:
 	goto out;
 }
 
+static int validate_evlist(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+
+	evlist__for_each(evlist, evsel) {
+		if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
+			return -EINVAL;
+	}
+	return 0;
+}
+
 static int trace__run(struct trace *trace, int argc, const char **argv)
 {
 	struct perf_evlist *evlist = trace->evlist;
@@ -3113,6 +3124,11 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused)
 	argc = parse_options_subcommand(argc, argv, trace_options, trace_subcommands,
 				 trace_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 
+	if (validate_evlist(trace.evlist)) {
+		pr_err("Only support tracepoint events!\n");
+		return -EINVAL;
+	}
+
 	if (trace.trace_pgfaults) {
 		trace.opts.sample_address = true;
 		trace.opts.sample_time = true;
-- 
1.8.3.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ