[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180208230153.182d38de89e2ce56263cb471@kernel.org>
Date: Thu, 8 Feb 2018 23:01:53 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Al Viro <viro@...IV.linux.org.uk>,
Masami Hiramatsu <mhiramat@...nel.org>,
Dmitry Safonov <0x7f454c46@...il.com>, stable@...r.kernel.org
Subject: Re: [RFC][PATCH 2/6] tracing: Fix parsing of globs with a wildcard
at the beginning
On Tue, 06 Feb 2018 17:43:40 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> From: "Steven Rostedt (VMware)" <rostedt@...dmis.org>
>
> Al Viro reported:
>
> For substring - sure, but what about something like "*a*b" and "a*b"?
> AFAICS, filter_parse_regex() ends up with identical results in both
> cases - MATCH_GLOB and *search = "a*b". And no way for the caller
> to tell one from another.
>
> Testing this with the following:
>
> # cd /sys/kernel/tracing
> # echo '*raw*lock' > set_ftrace_filter
> bash: echo: write error: Invalid argument
>
> With this patch:
>
> # echo '*raw*lock' > set_ftrace_filter
> # cat set_ftrace_filter
> _raw_read_trylock
> _raw_write_trylock
> _raw_read_unlock
> _raw_spin_unlock
> _raw_write_unlock
> _raw_spin_trylock
> _raw_spin_lock
> _raw_write_lock
> _raw_read_lock
>
> Al recommended not setting the search buffer to skip the first '*' unless we
> know we are not using MATCH_GLOB. This implements his suggested logic.
>
> Link: http://lkml.kernel.org/r/20180127170748.GF13338@ZenIV.linux.org.uk
>
> Cc: stable@...r.kernel.org
> Cc: Masami Hiramatsu <mhiramat@...nel.org>
> Fixes: 60f1d5e3bac44 ("ftrace: Support full glob matching")
> Reported-by: Al Viro <viro@...IV.linux.org.uk>
> Suggsted-by: Al Viro <viro@...IV.linux.org.uk>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
This looks good to me.
Reviewed-by: Masami Hiramatsu <mhiramat@...nel.org>
Thank you!
> ---
> kernel/trace/trace_events_filter.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index 61e7f0678d33..a764aec3c9a1 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -400,7 +400,6 @@ enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not)
> for (i = 0; i < len; i++) {
> if (buff[i] == '*') {
> if (!i) {
> - *search = buff + 1;
> type = MATCH_END_ONLY;
> } else if (i == len - 1) {
> if (type == MATCH_END_ONLY)
> @@ -410,14 +409,14 @@ enum regex_type filter_parse_regex(char *buff, int len, char **search, int *not)
> buff[i] = 0;
> break;
> } else { /* pattern continues, use full glob */
> - type = MATCH_GLOB;
> - break;
> + return MATCH_GLOB;
> }
> } else if (strchr("[?\\", buff[i])) {
> - type = MATCH_GLOB;
> - break;
> + return MATCH_GLOB;
> }
> }
> + if (buff[0] == '*')
> + *search = buff + 1;
>
> return type;
> }
> --
> 2.15.1
>
>
--
Masami Hiramatsu <mhiramat@...nel.org>
Powered by blists - more mailing lists