]> git.baikalelectronics.ru Git - kernel.git/commit
ftrace: Remove incorrect setting of glob search field
authorSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 6 Feb 2018 03:05:31 +0000 (22:05 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Thu, 8 Feb 2018 15:11:11 +0000 (10:11 -0500)
commit8edec518aba8f4a7338880c2744f93419cb8f24b
treef0b26afa50ad73d1daa8dc00268b77c0ee033c60
parent675d59f84f6b0b8b9dc78a8534ec38cd2ef6d8fd
ftrace: Remove incorrect setting of glob search field

__unregister_ftrace_function_probe() will incorrectly parse the glob filter
because it resets the search variable that was setup by filter_parse_regex().

Al Viro reported this:

    After that call of filter_parse_regex() we could have func_g.search not
    equal to glob only if glob started with '!' or '*'.  In the former case
    we would've buggered off with -EINVAL (not = 1).  In the latter we
    would've set func_g.search equal to glob + 1, calculated the length of
    that thing in func_g.len and proceeded to reset func_g.search back to
    glob.

    Suppose the glob is e.g. *foo*.  We end up with
    func_g.type = MATCH_MIDDLE_ONLY;
    func_g.len = 3;
    func_g.search = "*foo";
    Feeding that to ftrace_match_record() will not do anything sane - we
    will be looking for names containing "*foo" (->len is ignored for that
    one).

Link: http://lkml.kernel.org/r/20180127031706.GE13338@ZenIV.linux.org.uk
Cc: stable@vger.kernel.org
Fixes: afd8da98c5e4d ("ftrace: Introduce ftrace_glob structure")
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/ftrace.c