Skip to content

Commit

Permalink
ftrace: Fix MATCH_END_ONLY function filter
Browse files Browse the repository at this point in the history
For '*foo' pattern, we should allow any string ending with
'foo', but ftrace filter incorrectly disallows strings
like bar_foo_foo:

  # echo '*io' > set_ftrace_filter
  # cat set_ftrace_filter | grep 'req_bio_endio'
  # cat available_filter_functions | grep 'req_bio_endio'
  req_bio_endio

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4B4E870E.6060607@cn.fujitsu.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Li Zefan authored and Steven Rostedt committed Jan 15, 2010
1 parent b82a404 commit 751e998
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
static int ftrace_match(char *str, char *regex, int len, int type)
{
int matched = 0;
char *ptr;
int slen;

switch (type) {
case MATCH_FULL:
Expand All @@ -1706,8 +1706,8 @@ static int ftrace_match(char *str, char *regex, int len, int type)
matched = 1;
break;
case MATCH_END_ONLY:
ptr = strstr(str, regex);
if (ptr && (ptr[len] == 0))
slen = strlen(str);
if (slen >= len && memcmp(str + slen - len, regex, len) == 0)
matched = 1;
break;
}
Expand Down

0 comments on commit 751e998

Please sign in to comment.