linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Tom Zanussi <zanussi@kernel.org>, Steven Rostedt <rostedt@goodmis.org>
Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org,
	bigeasy@linutronix.de, joel@joelfernandes.org,
	linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: [RFC PATCH 2/7] tracing/probe: Check event name length correctly
Date: Wed, 13 Mar 2019 21:27:52 +0900	[thread overview]
Message-ID: <155248007244.10815.13509556763357004928.stgit@devnote2> (raw)
In-Reply-To: <155248005229.10815.334731901778152247.stgit@devnote2>

Ensure given name of event is not too long when parsing it,
and fix to update event name offset correctly when the group
name is given. For example, this makes probe event to check
the "p:foo/" error case correctly.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 kernel/trace/trace_probe.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index 89da34b326e3..4cd50913cb5d 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -159,6 +159,7 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
 				char *buf)
 {
 	const char *slash, *event = *pevent;
+	int len;
 
 	slash = strchr(event, '/');
 	if (slash) {
@@ -173,10 +174,15 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
 		strlcpy(buf, event, slash - event + 1);
 		*pgroup = buf;
 		*pevent = slash + 1;
+		event = *pevent;
 	}
-	if (strlen(event) == 0) {
+	len = strlen(event);
+	if (len == 0) {
 		pr_info("Event name is not specified\n");
 		return -EINVAL;
+	} else if (len > MAX_EVENT_NAME_LEN) {
+		pr_info("Event name is too long\n");
+		return -E2BIG;
 	}
 	return 0;
 }


  parent reply	other threads:[~2019-03-13 12:27 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 12:27 [RFC PATCH 0/7] tracing: Use common error_log with probe events Masami Hiramatsu
2019-03-13 12:27 ` [RFC PATCH 1/7] tracing/probe: Check maxactive error cases Masami Hiramatsu
2019-03-13 13:20   ` Steven Rostedt
2019-03-13 14:37     ` Masami Hiramatsu
2019-03-13 14:51       ` Steven Rostedt
2019-03-13 22:43         ` Masami Hiramatsu
2019-03-13 12:27 ` Masami Hiramatsu [this message]
2019-03-13 12:28 ` [RFC PATCH 3/7] tracing/probe: Check the size of argument name and body Masami Hiramatsu
2019-03-13 12:28 ` [RFC PATCH 4/7] tracing/probe: Check event/group naming rule at parsing Masami Hiramatsu
2019-03-13 13:23   ` Steven Rostedt
2019-03-13 15:04     ` Masami Hiramatsu
2019-03-13 15:23       ` Steven Rostedt
2019-03-13 22:47         ` Masami Hiramatsu
2019-03-13 12:28 ` [RFC PATCH 5/7] tracing/probe: Verify alloc_trace_*probe() result Masami Hiramatsu
2019-03-13 12:28 ` [RFC PATCH 6/7] tracing: Use tracing error_log with probe events Masami Hiramatsu
2019-03-13 12:28 ` [RFC PATCH 7/7] selftests/ftrace: Add error_log testcase for kprobe errors Masami Hiramatsu
2019-03-13 20:15 ` [RFC PATCH 0/7] tracing: Use common error_log with probe events Tom Zanussi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=155248007244.10815.13509556763357004928.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=zanussi@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).