From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Shuah Khan <shuah@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Hari Bathini <hbathini@linux.ibm.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 4/8] tracing: probe-events: Log errro for exceeding the number of arguments
Date: Mon, 3 Mar 2025 11:17:21 +0900 [thread overview]
Message-ID: <20250303111721.87cd676bacaa29326a575452@kernel.org> (raw)
In-Reply-To: <174055075075.4079315.10916648136898316476.stgit@mhiramat.tok.corp.google.com>
On Wed, 26 Feb 2025 15:19:10 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> Add error message when the number of arguments exceeeds the limitation.
>
Hmm, this is not a fix patch so this should be handled as enhancement.
I'll drop this from probes/fixes.
Thanks,
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> ---
> kernel/trace/trace_eprobe.c | 2 ++
> kernel/trace/trace_fprobe.c | 5 ++++-
> kernel/trace/trace_kprobe.c | 5 ++++-
> kernel/trace/trace_probe.h | 1 +
> kernel/trace/trace_uprobe.c | 9 +++++++--
> 5 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> index 82fd637cfc19..af9fa0632b57 100644
> --- a/kernel/trace/trace_eprobe.c
> +++ b/kernel/trace/trace_eprobe.c
> @@ -913,6 +913,8 @@ static int __trace_eprobe_create(int argc, const char *argv[])
> }
>
> if (argc - 2 > MAX_TRACE_ARGS) {
> + trace_probe_log_set_index(2);
> + trace_probe_log_err(0, TOO_MANY_ARGS);
> ret = -E2BIG;
> goto error;
> }
> diff --git a/kernel/trace/trace_fprobe.c b/kernel/trace/trace_fprobe.c
> index e27305d31fc5..372936163c21 100644
> --- a/kernel/trace/trace_fprobe.c
> +++ b/kernel/trace/trace_fprobe.c
> @@ -1201,8 +1201,11 @@ static int trace_fprobe_create_internal(int argc, const char *argv[],
> argc = new_argc;
> argv = new_argv;
> }
> - if (argc > MAX_TRACE_ARGS)
> + if (argc > MAX_TRACE_ARGS) {
> + trace_probe_log_set_index(2);
> + trace_probe_log_err(0, TOO_MANY_ARGS);
> return -E2BIG;
> + }
>
> ret = traceprobe_expand_dentry_args(argc, argv, &dbuf);
> if (ret)
> diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> index d8d5f18a141a..8287b175667f 100644
> --- a/kernel/trace/trace_kprobe.c
> +++ b/kernel/trace/trace_kprobe.c
> @@ -1007,8 +1007,11 @@ static int trace_kprobe_create_internal(int argc, const char *argv[],
> argc = new_argc;
> argv = new_argv;
> }
> - if (argc > MAX_TRACE_ARGS)
> + if (argc > MAX_TRACE_ARGS) {
> + trace_probe_log_set_index(2);
> + trace_probe_log_err(0, TOO_MANY_ARGS);
> return -E2BIG;
> + }
>
> ret = traceprobe_expand_dentry_args(argc, argv, &dbuf);
> if (ret)
> diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
> index c47ca002347a..6075afc8ea67 100644
> --- a/kernel/trace/trace_probe.h
> +++ b/kernel/trace/trace_probe.h
> @@ -546,6 +546,7 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
> 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(TOO_MANY_ARGS, "Too many arguments are specified"), \
> C(TOO_MANY_EARGS, "Too many entry arguments specified"),
>
> #undef C
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index ccc762fbb69c..3386439ec9f6 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -562,8 +562,14 @@ static int __trace_uprobe_create(int argc, const char **argv)
>
> if (argc < 2)
> return -ECANCELED;
> - if (argc - 2 > MAX_TRACE_ARGS)
> +
> + trace_probe_log_init("trace_uprobe", argc, argv);
> +
> + if (argc - 2 > MAX_TRACE_ARGS) {
> + trace_probe_log_set_index(2);
> + trace_probe_log_err(0, TOO_MANY_ARGS);
> return -E2BIG;
> + }
>
> if (argv[0][1] == ':')
> event = &argv[0][2];
> @@ -582,7 +588,6 @@ static int __trace_uprobe_create(int argc, const char **argv)
> return -ECANCELED;
> }
>
> - trace_probe_log_init("trace_uprobe", argc, argv);
> trace_probe_log_set_index(1); /* filename is the 2nd argument */
>
> *arg++ = '\0';
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2025-03-03 2:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 6:18 [PATCH 0/8] tracing: probes: Fixes and enhancing error logs Masami Hiramatsu (Google)
2025-02-26 6:18 ` [PATCH 1/8] tracing: tprobe-events: Fix a memory leak when tprobe with $retval Masami Hiramatsu (Google)
2025-02-26 15:09 ` Steven Rostedt
2025-02-26 6:18 ` [PATCH 2/8] tracing: tprobe-events: Reject invalid tracepoint name Masami Hiramatsu (Google)
2025-02-26 15:10 ` Steven Rostedt
2025-02-26 15:50 ` Markus Elfring
2025-02-26 6:19 ` [PATCH 3/8] tracing: fprobe-events: Log error for exceeding the number of entry args Masami Hiramatsu (Google)
2025-02-26 15:22 ` Steven Rostedt
2025-02-26 22:10 ` Masami Hiramatsu
2025-02-26 6:19 ` [PATCH 4/8] tracing: probe-events: Log errro for exceeding the number of arguments Masami Hiramatsu (Google)
2025-02-26 15:29 ` Steven Rostedt
2025-02-26 16:13 ` Markus Elfring
2025-02-27 0:19 ` Masami Hiramatsu
2025-02-27 10:13 ` [4/8] " Markus Elfring
2025-03-03 2:17 ` Masami Hiramatsu [this message]
2025-02-26 6:19 ` [PATCH 5/8] tracing: probe-events: Remove unused MAX_ARG_BUF_LEN macro Masami Hiramatsu (Google)
2025-02-26 15:32 ` Steven Rostedt
2025-02-26 6:19 ` [PATCH 6/8] selftests/ftrace: Expand the tprobe event test to check wrong format Masami Hiramatsu (Google)
2025-02-26 6:19 ` [PATCH 7/8] selftests/ftrace: Add new syntax error test Masami Hiramatsu (Google)
2025-02-26 6:19 ` [PATCH 8/8] selftests/ftrace: Add dynamic events argument limitation test case Masami Hiramatsu (Google)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250303111721.87cd676bacaa29326a575452@kernel.org \
--to=mhiramat@kernel.org \
--cc=hbathini@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox