mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Tom Zanussi <zanussi@kernel.org>
Subject: Re: [PATCH] tracing/synthetic_events: Fix use when created by dynamic_events file
Date: Thu, 7 Oct 2021 10:19:52 +0900	[thread overview]
Message-ID: <20211007101952.d9d282257b9c49fe699c0679@kernel.org> (raw)
In-Reply-To: <20211006115317.2cfcc742@gandalf.local.home>

On Wed, 6 Oct 2021 11:53:17 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> 
> The dynamic_events file can create kprobe, uprobe, event probes as well as
> synthetic events. New dynamic events will also be created by this file.
> Each of these kinds of events register a "create" function, that gets
> called, and if the prefix does not match the type of event, the create
> function is to return -ECANCELED to tell the dynamic event code that the
> command does not belong to it, and other events should be tried.
> 
> The synthetic event does some format checking before it determines that it
> is the event that should be created, and if that format check does not
> match, it will return an error, telling the dynamic event code that it was
> the expected event to be created and that the input had an error. This
> returns an error code back to the user. But unfortunately, because it does
> the check before it determines that it is indeed the proper event to parse
> the input, it may fail the call even though the input is a proper syntax
> for another event type.
> 
> Have it confirm that the input is for the synthetic event before it
> returns an error due to parsing failure.
> 
> Fixes: c9e759b1e8456 ("tracing: Rework synthetic event command parsing")
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  kernel/trace/trace_events_synth.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
> index d54094b7a9d7..feb87e5817e9 100644
> --- a/kernel/trace/trace_events_synth.c
> +++ b/kernel/trace/trace_events_synth.c
> @@ -2045,11 +2045,17 @@ static int create_synth_event(const char *raw_command)
>  {
>  	char *fields, *p;
>  	const char *name;
> -	int len, ret = 0;
> +	int len, ret;
>  
>  	raw_command = skip_spaces(raw_command);
>  	if (raw_command[0] == '\0')
> -		return ret;
> +		return -ECANCELED;

Good catch! BTW, I thought trace_parse_run_command() skips such empty line.

Anyway,

Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you,

> +
> +	name = raw_command;
> +
> +	if (name[0] != 's' || name[1] != ':')
> +		return -ECANCELED;
> +	name += 2;
>  
>  	last_cmd_set(raw_command);
>  
> @@ -2061,12 +2067,6 @@ static int create_synth_event(const char *raw_command)
>  
>  	fields = skip_spaces(p);
>  
> -	name = raw_command;
> -
> -	if (name[0] != 's' || name[1] != ':')
> -		return -ECANCELED;
> -	name += 2;
> -
>  	/* This interface accepts group name prefix */
>  	if (strchr(name, '/')) {
>  		len = str_has_prefix(name, SYNTH_SYSTEM "/");
> -- 
> 2.31.1
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2021-10-07  1:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 15:53 Steven Rostedt
2021-10-07  1:19 ` Masami Hiramatsu [this message]
2021-10-07  1:28   ` Steven Rostedt

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=20211007101952.d9d282257b9c49fe699c0679@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=zanussi@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

all inboxes | Powered by JetHome®