Skip to content

Commit a23fbee

Browse files
mhiramatgregkh
authored andcommitted
tracing: tprobe-events: Reject invalid tracepoint name
commit d045365 upstream. 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b4a92f3 commit a23fbee

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
@@ -1018,6 +1018,19 @@ static int parse_symbol_and_return(int argc, const char *argv[],
10181018
if (*is_return)
10191019
return 0;
10201020

1021+
if (is_tracepoint) {
1022+
tmp = *symbol;
1023+
while (*tmp && (isalnum(*tmp) || *tmp == '_'))
1024+
tmp++;
1025+
if (*tmp) {
1026+
/* find a wrong character. */
1027+
trace_probe_log_err(tmp - *symbol, BAD_TP_NAME);
1028+
kfree(*symbol);
1029+
*symbol = NULL;
1030+
return -EINVAL;
1031+
}
1032+
}
1033+
10211034
/* If there is $retval, this should be a return fprobe. */
10221035
for (i = 2; i < argc; i++) {
10231036
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)