]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
tracing: fprobe-events: Log error for exceeding the number of entry args
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 26 Feb 2025 06:19:02 +0000 (15:19 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Thu, 27 Feb 2025 00:11:51 +0000 (09:11 +0900)
Add error message when the number of entry argument exceeds the
maximum size of entry data.
This is currently checked when registering fprobe, but in this case
no error message is shown in the error_log file.

Link: https://lore.kernel.org/all/174055074269.4079315.17809232650360988538.stgit@mhiramat.tok.corp.google.com/
Fixes: 25f00e40ce79 ("tracing/probes: Support $argN in return probe (kprobe and fprobe)")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_fprobe.c
kernel/trace/trace_probe.h

index 85f037dc14623d08ffaef37d1d1612738d44a431..e27305d31fc57c167fd2ab62a8eb5bb34ae59bd8 100644 (file)
@@ -1230,6 +1230,11 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
        if (is_return && tf->tp.entry_arg) {
                tf->fp.entry_handler = trace_fprobe_entry_handler;
                tf->fp.entry_data_size = traceprobe_get_entry_data_size(&tf->tp);
+               if (ALIGN(tf->fp.entry_data_size, sizeof(long)) > MAX_FPROBE_DATA_SIZE) {
+                       trace_probe_log_set_index(2);
+                       trace_probe_log_err(0, TOO_MANY_EARGS);
+                       return -E2BIG;
+               }
        }
 
        ret = traceprobe_set_print_fmt(&tf->tp,
index fba3ede8705419c953e8f0e0a0c712a50acd049c..c47ca002347a7b035a4e8d26b25df07fc50a6fe3 100644 (file)
@@ -545,7 +545,8 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
        C(NO_BTF_FIELD,         "This field is not found."),    \
        C(BAD_BTF_TID,          "Failed to get BTF type info."),\
        C(BAD_TYPE4STR,         "This type does not fit for string."),\
-       C(NEED_STRING_TYPE,     "$comm and immediate-string only accepts string type"),
+       C(NEED_STRING_TYPE,     "$comm and immediate-string only accepts string type"),\
+       C(TOO_MANY_EARGS,       "Too many entry arguments specified"),
 
 #undef C
 #define C(a, b)                TP_ERR_##a