From: Jiri Olsa <jolsa@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] ftrace: Handle commands when closing set_ftrace_filter file
Date: Thu, 13 May 2021 22:24:19 +0200 [thread overview]
Message-ID: <YJ2K80OWCmoxy4n8@krava> (raw)
In-Reply-To: <20210505104818.24358ef7@gandalf.local.home>
On Wed, May 05, 2021 at 10:48:18AM -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> # echo switch_mm:traceoff > /sys/kernel/tracing/set_ftrace_filter
>
> will cause switch_mm to stop tracing by the traceoff command.
>
> # echo -n switch_mm:traceoff > /sys/kernel/tracing/set_ftrace_filter
>
> does nothing.
>
> The reason is that the parsing in the write function only processes
> commands if it finished parsing (there is white space written after the
> command). That's to handle:
>
> write(fd, "switch_mm:", 10);
> write(fd, "traceoff", 8);
>
> cases, where the command is broken over multiple writes.
>
> The problem is if the file descriptor is closed, then the write call is
> not processed, and the command needs to be processed in the release code.
> The release code can handle matching of functions, but does not handle
> commands.
>
> Cc: stable@vger.kernel.org
> Fixes: eda1e32855656 ("tracing: handle broken names in ftrace filter")
nice, breaking kernel since 2009.. I'll put that on t-shirt ;-)
I saw the patch got already merged, FWIW:
Acked-by: Jiri Olsa <jolsa@kernel.org>
jirka
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
> kernel/trace/ftrace.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 057e962ca5ce..c57508445faa 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -5591,7 +5591,10 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
>
> parser = &iter->parser;
> if (trace_parser_loaded(parser)) {
> - ftrace_match_records(iter->hash, parser->buffer, parser->idx);
> + int enable = !(iter->flags & FTRACE_ITER_NOTRACE);
> +
> + ftrace_process_regex(iter, parser->buffer,
> + parser->idx, enable);
> }
>
> trace_parser_put(parser);
> --
> 2.29.2
>
next prev parent reply other threads:[~2021-05-13 20:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-05 14:48 [PATCH] ftrace: Handle commands when closing set_ftrace_filter file Steven Rostedt
2021-05-13 20:24 ` Jiri Olsa [this message]
2021-05-13 20:45 ` Steven Rostedt
2021-05-13 20:58 ` Jiri Olsa
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=YJ2K80OWCmoxy4n8@krava \
--to=jolsa@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.