public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Tom Zanussi <zanussi@kernel.org>
Cc: rostedt@goodmis.org, axelrasmussen@google.com,
	mhiramat@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] tracing: Check that the synthetic event and field names are legal
Date: Sat, 10 Oct 2020 23:41:56 +0900	[thread overview]
Message-ID: <20201010234156.61a8743510a05878ccfda0bf@kernel.org> (raw)
In-Reply-To: <82b1b533c54f83bb7cd466a32244533717c8f291.1602255803.git.zanussi@kernel.org>

On Fri,  9 Oct 2020 10:17:09 -0500
Tom Zanussi <zanussi@kernel.org> wrote:

> Call the is_good_name() function used by probe events to make sure
> synthetic event and field names don't contain illegal characters and
> cause unexpected parsing of synthetic event commands.
> 

I've tested it. This looks good to me.

/sys/kernel/debug/tracing # echo "myevent char str]" >> synthetic_events 
sh: write error: Invalid argument
/sys/kernel/debug/tracing # echo "myevent char str;[]" >> synthetic_events 
sh: write error: Invalid argument

It works correctly now :)

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

Thanks!

> Fixes: 4b147936fa50 (tracing: Add support for 'synthetic' events)
> Reported-by: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Tom Zanussi <zanussi@kernel.org>
> ---
>  kernel/trace/trace_events_synth.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
> index b19e2f4159ab..8c9d6e464da0 100644
> --- a/kernel/trace/trace_events_synth.c
> +++ b/kernel/trace/trace_events_synth.c
> @@ -572,6 +572,10 @@ static struct synth_field *parse_synth_field(int argc, const char **argv,
>  		ret = -ENOMEM;
>  		goto free;
>  	}
> +	if (!is_good_name(field->name)) {
> +		ret = -EINVAL;
> +		goto free;
> +	}
>  
>  	if (field_type[0] == ';')
>  		field_type++;
> @@ -1112,6 +1116,11 @@ static int __create_synth_event(int argc, const char *name, const char **argv)
>  
>  	mutex_lock(&event_mutex);
>  
> +	if (!is_good_name(name)) {
> +		ret = -EINVAL;
> +		goto out;
> +	}
> +
>  	event = find_synth_event(name);
>  	if (event) {
>  		ret = -EEXIST;
> -- 
> 2.17.1
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2020-10-10 23:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 15:17 [PATCH 0/5] tracing: Synthetic event dynamic string fixes Tom Zanussi
2020-10-09 15:17 ` [PATCH 1/5] tracing: Don't show dynamic string internals in synthetic event description Tom Zanussi
2020-10-10 15:03   ` Masami Hiramatsu
2020-10-12 15:37     ` Tom Zanussi
2020-10-09 15:17 ` [PATCH 2/5] tracing: Move is_good_name() from trace_probe.h to trace.h Tom Zanussi
2020-10-10 14:39   ` Masami Hiramatsu
2020-10-09 15:17 ` [PATCH 3/5] tracing: Check that the synthetic event and field names are legal Tom Zanussi
2020-10-10 14:41   ` Masami Hiramatsu [this message]
2020-10-09 15:17 ` [PATCH 4/5] tracing: Add synthetic event error logging Tom Zanussi
2020-10-10 14:57   ` Masami Hiramatsu
2020-10-12 15:34     ` Tom Zanussi
2020-10-09 15:17 ` [PATCH 5/5] selftests/ftrace: Change synthetic event name for inter-event-combined test Tom Zanussi
2020-10-10 14:43   ` Masami Hiramatsu
2020-10-09 20:35 ` [PATCH 0/5] tracing: Synthetic event dynamic string fixes Axel Rasmussen
2020-10-09 21:10   ` Tom Zanussi
2020-10-12 15:13 ` Steven Rostedt
2020-10-12 15:38   ` Tom Zanussi

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=20201010234156.61a8743510a05878ccfda0bf@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=axelrasmussen@google.com \
    --cc=linux-kernel@vger.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