Skip to content

Commit dec65d7

Browse files
mhiramatrostedt
authored andcommitted
tracing/probe: Check event name length correctly
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. Link: http://lkml.kernel.org/r/155253782046.14922.14724124823730168629.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 287c038 commit dec65d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

kernel/trace/trace_probe.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
159159
char *buf)
160160
{
161161
const char *slash, *event = *pevent;
162+
int len;
162163

163164
slash = strchr(event, '/');
164165
if (slash) {
@@ -173,10 +174,15 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
173174
strlcpy(buf, event, slash - event + 1);
174175
*pgroup = buf;
175176
*pevent = slash + 1;
177+
event = *pevent;
176178
}
177-
if (strlen(event) == 0) {
179+
len = strlen(event);
180+
if (len == 0) {
178181
pr_info("Event name is not specified\n");
179182
return -EINVAL;
183+
} else if (len > MAX_EVENT_NAME_LEN) {
184+
pr_info("Event name is too long\n");
185+
return -E2BIG;
180186
}
181187
return 0;
182188
}

0 commit comments

Comments
 (0)