Skip to content

Commit d045365

Browse files
committed
tracing: tprobe-events: Reject invalid tracepoint name
Commit 57a7e6d ("tracing/fprobe: Support raw tracepoints on future loaded modules") allows user to set a tprobe on non-exist tracepoint but it does not check the tracepoint name is acceptable. So it leads tprobe has a wrong character for events (e.g. with subsystem prefix). In this case, the event is not shown in the events directory. Reject such invalid tracepoint name. The tracepoint name must consist of alphabet or digit or '_'. Link: https://lore.kernel.org/all/174055073461.4079315.15875502830565214255.stgit@mhiramat.tok.corp.google.com/ Fixes: 57a7e6d ("tracing/fprobe: Support raw tracepoints on future loaded modules") Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Cc: stable@vger.kernel.org
1 parent ac965d7 commit d045365

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

kernel/trace/trace_fprobe.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,19 @@ static int parse_symbol_and_return(int argc, const char *argv[],
10491049
if (*is_return)
10501050
return 0;
10511051

1052+
if (is_tracepoint) {
1053+
tmp = *symbol;
1054+
while (*tmp && (isalnum(*tmp) || *tmp == '_'))
1055+
tmp++;
1056+
if (*tmp) {
1057+
/* find a wrong character. */
1058+
trace_probe_log_err(tmp - *symbol, BAD_TP_NAME);
1059+
kfree(*symbol);
1060+
*symbol = NULL;
1061+
return -EINVAL;
1062+
}
1063+
}
1064+
10521065
/* If there is $retval, this should be a return fprobe. */
10531066
for (i = 2; i < argc; i++) {
10541067
tmp = strstr(argv[i], "$retval");

kernel/trace/trace_probe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
481481
C(NON_UNIQ_SYMBOL, "The symbol is not unique"), \
482482
C(BAD_RETPROBE, "Retprobe address must be an function entry"), \
483483
C(NO_TRACEPOINT, "Tracepoint is not found"), \
484+
C(BAD_TP_NAME, "Invalid character in tracepoint name"),\
484485
C(BAD_ADDR_SUFFIX, "Invalid probed address suffix"), \
485486
C(NO_GROUP_NAME, "Group name is not specified"), \
486487
C(GROUP_TOO_LONG, "Group name is too long"), \

0 commit comments

Comments
 (0)