mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] apparent bogosity in unregister_ftrace_function_probe_func()
Date: Mon, 5 Feb 2018 17:54:33 -0500	[thread overview]
Message-ID: <20180205175433.6cd369db@gandalf.local.home> (raw)
In-Reply-To: <20180129225942.f2aec926e2ea223c52c34169@kernel.org>

On Mon, 29 Jan 2018 22:59:42 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> On Sat, 27 Jan 2018 17:07:48 +0000
> Al Viro <viro@ZenIV.linux.org.uk> wrote:
> 
> > On Sat, Jan 27, 2018 at 01:59:56PM +0000, Dmitry Safonov wrote:  
> > >   
> > > > Incidentally, shouldn't filter_parse_regex("*[ab]", 5, &s, &not)
> > > > end up with s = "*[ab]"?  We are returning MATCH_GLOB, after all,
> > > > so we want the entire pattern there...  I would've assumed that
> > > > this is what the code in unregister_ftrace_function_probe_func()
> > > > is trying to compensate for, the first oddity predates MATCH_GLOB...  
> > > 
> > > No, I don't think filter_parse_regex() should return the full regex..
> > > ftrace_match() expects search would be processed string, not a glob.
> > > So, this unnecessary assignment broke unregistering multiple kprobs
> > > with a middle/end pattern..  
> > 
> > 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.
> > 
> > IOW, it's a different bug sometimes obscured by the one in
> > unregister_ftrace_function_probe_func().  filter_parse_regex()
> > ought to revert to *search = buff; when it decides to return
> > MATCH_GLOB.  Or something like
> >         for (i = 0; i < len; i++) {
> >                 if (buff[i] == '*') {
> >                         if (!i) {
> >                                 type = MATCH_END_ONLY;
> >                         } else if (i == len - 1) {
> >                                 if (type == MATCH_END_ONLY)
> >                                         type = MATCH_MIDDLE_ONLY;
> >                                 else
> >                                         type = MATCH_FRONT_ONLY;
> >                                 buff[i] = 0;
> >                                 break;
> >                         } else {        /* pattern continues, use full glob */
> >                                 return MATCH_GLOB;
> >                         }
> >                 } else if (strchr("[?\\", buff[i])) {
> >                         return MATCH_GLOB;
> >                 }
> >         }
> >         if (buff[0] == '*')
> >                 *search = buff + 1;
> > for that matter - i.e. delay that "we want everything past the first character"
> > until we are certain it's not a MATCH_GLOB.  
> 
> Looks nice to me!
> 

I'll implement this code giving Al credit and referencing this email
thread. Anyone have objections to that?

Thanks!

-- Steve

  reply	other threads:[~2018-02-05 22:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-27  3:17 Al Viro
2018-01-27 13:59 ` Dmitry Safonov
2018-01-27 17:07   ` Al Viro
2018-01-28 10:31     ` Steven Rostedt
2018-01-29 13:59     ` Masami Hiramatsu
2018-02-05 22:54       ` Steven Rostedt [this message]
2018-02-06  1:25         ` Dmitry Safonov
2018-02-06  2:26         ` Masami Hiramatsu
2018-02-06  2:40           ` Steven Rostedt
2018-02-06  2:44             ` Dmitry Safonov
2018-02-06  2:48               ` Steven Rostedt
2018-02-06  2:53                 ` Dmitry Safonov
2018-01-29 13:49 ` Masami Hiramatsu

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=20180205175433.6cd369db@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=0x7f454c46@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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®