Skip to content

Commit 5b7a962

Browse files
mhiramatrostedt
authored andcommitted
tracing/probe: Check event/group naming rule at parsing
Check event and group naming rule at parsing it instead of allocating probes. Link: http://lkml.kernel.org/r/155253784064.14922.2336893061156236237.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent b4443c1 commit 5b7a962

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

kernel/trace/trace_kprobe.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static struct trace_kprobe *alloc_trace_kprobe(const char *group,
221221

222222
tk->rp.maxactive = maxactive;
223223

224-
if (!event || !is_good_name(event)) {
224+
if (!event || !group) {
225225
ret = -EINVAL;
226226
goto error;
227227
}
@@ -231,11 +231,6 @@ static struct trace_kprobe *alloc_trace_kprobe(const char *group,
231231
if (!tk->tp.call.name)
232232
goto error;
233233

234-
if (!group || !is_good_name(group)) {
235-
ret = -EINVAL;
236-
goto error;
237-
}
238-
239234
tk->tp.class.system = kstrdup(group, GFP_KERNEL);
240235
if (!tk->tp.class.system)
241236
goto error;

kernel/trace/trace_probe.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
172172
return -E2BIG;
173173
}
174174
strlcpy(buf, event, slash - event + 1);
175+
if (!is_good_name(buf)) {
176+
pr_info("Group name must follow the same rules as C identifiers\n");
177+
return -EINVAL;
178+
}
175179
*pgroup = buf;
176180
*pevent = slash + 1;
177181
event = *pevent;
@@ -184,6 +188,10 @@ int traceprobe_parse_event_name(const char **pevent, const char **pgroup,
184188
pr_info("Event name is too long\n");
185189
return -E2BIG;
186190
}
191+
if (!is_good_name(event)) {
192+
pr_info("Event name must follow the same rules as C identifiers\n");
193+
return -EINVAL;
194+
}
187195
return 0;
188196
}
189197

kernel/trace/trace_uprobe.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,7 @@ alloc_trace_uprobe(const char *group, const char *event, int nargs, bool is_ret)
266266
{
267267
struct trace_uprobe *tu;
268268

269-
if (!event || !is_good_name(event))
270-
return ERR_PTR(-EINVAL);
271-
272-
if (!group || !is_good_name(group))
269+
if (!event || !group)
273270
return ERR_PTR(-EINVAL);
274271

275272
tu = kzalloc(SIZEOF_TRACE_UPROBE(nargs), GFP_KERNEL);

0 commit comments

Comments
 (0)