Skip to content

Commit 57faaa0

Browse files
committed
tracing: probe-events: Log error for exceeding the number of arguments
Add error message when the number of arguments exceeds the limitation. Link: https://lore.kernel.org/all/174055075075.4079315.10916648136898316476.stgit@mhiramat.tok.corp.google.com/ Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 38fec10 commit 57faaa0

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

kernel/trace/trace_eprobe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,8 @@ static int __trace_eprobe_create(int argc, const char *argv[])
913913
}
914914

915915
if (argc - 2 > MAX_TRACE_ARGS) {
916+
trace_probe_log_set_index(2);
917+
trace_probe_log_err(0, TOO_MANY_ARGS);
916918
ret = -E2BIG;
917919
goto error;
918920
}

kernel/trace/trace_fprobe.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,11 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
11991199
argc = new_argc;
12001200
argv = new_argv;
12011201
}
1202-
if (argc > MAX_TRACE_ARGS)
1202+
if (argc > MAX_TRACE_ARGS) {
1203+
trace_probe_log_set_index(2);
1204+
trace_probe_log_err(0, TOO_MANY_ARGS);
12031205
return -E2BIG;
1206+
}
12041207

12051208
ret = traceprobe_expand_dentry_args(argc, argv, &dbuf);
12061209
if (ret)

kernel/trace/trace_kprobe.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,11 @@ static int trace_kprobe_create_internal(int argc, const char *argv[],
10071007
argc = new_argc;
10081008
argv = new_argv;
10091009
}
1010-
if (argc > MAX_TRACE_ARGS)
1010+
if (argc > MAX_TRACE_ARGS) {
1011+
trace_probe_log_set_index(2);
1012+
trace_probe_log_err(0, TOO_MANY_ARGS);
10111013
return -E2BIG;
1014+
}
10121015

10131016
ret = traceprobe_expand_dentry_args(argc, argv, &dbuf);
10141017
if (ret)

kernel/trace/trace_probe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
545545
C(BAD_BTF_TID, "Failed to get BTF type info."),\
546546
C(BAD_TYPE4STR, "This type does not fit for string."),\
547547
C(NEED_STRING_TYPE, "$comm and immediate-string only accepts string type"),\
548+
C(TOO_MANY_ARGS, "Too many arguments are specified"), \
548549
C(TOO_MANY_EARGS, "Too many entry arguments specified"),
549550

550551
#undef C

kernel/trace/trace_uprobe.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,14 @@ static int __trace_uprobe_create(int argc, const char **argv)
562562

563563
if (argc < 2)
564564
return -ECANCELED;
565-
if (argc - 2 > MAX_TRACE_ARGS)
565+
566+
trace_probe_log_init("trace_uprobe", argc, argv);
567+
568+
if (argc - 2 > MAX_TRACE_ARGS) {
569+
trace_probe_log_set_index(2);
570+
trace_probe_log_err(0, TOO_MANY_ARGS);
566571
return -E2BIG;
572+
}
567573

568574
if (argv[0][1] == ':')
569575
event = &argv[0][2];
@@ -582,7 +588,6 @@ static int __trace_uprobe_create(int argc, const char **argv)
582588
return -ECANCELED;
583589
}
584590

585-
trace_probe_log_init("trace_uprobe", argc, argv);
586591
trace_probe_log_set_index(1); /* filename is the 2nd argument */
587592

588593
*arg++ = '\0';

0 commit comments

Comments
 (0)