ftrace: Fix unmatching locking in ftrace_regex_write()
PATCH 1/3 ftrace: Fix unmatching locking in ftrace_regex_write()
# echo 'do_open : foo' > set_ftrace_filter (still holding ftrace_regex_lock when returning to user space!)
---
This patch is for .32
--- kernel/trace/ftrace.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +3 -3
@@ -2199,15 +2199,15 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, ret =ftrace_process_regex (parser->buffer, parser->idx, enable);if (ret) - goto out; + goto out_unlock;trace_parser_clear (parser); } ret = read; - +out_unlock:mutex_unlock (&ftrace_regex_lock); -out: +return ret; }
Signature · 1 line
1.6.3
PATCH 2/3 ftrace: Return EINVAL when writing invalid val to set_ftrace_filter
Currently it doesn't warn user on invald value:
# echo nonexist_symbol > set_ftrace_filter
Better make it return failure.
--- kernel/trace/ftrace.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +9 -3
@@ -1724,7 +1724,7 @@ ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type)return ftrace_match (str, regex, len, type); } -static void ftrace_match_records (char *buff,int len,int enable) +static int ftrace_match_records (char *buff,int len,int enable) {unsigned int search_len;struct ftrace_page *pg;
@@ -1733,6 +1733,7 @@ static void ftrace_match_records(char *buff, int len, int enable)char *search;int type;int not; +int found =0 ; flag = enable ?FTRACE_FL_FILTER :FTRACE_FL_NOTRACE ; type =filter_parse_regex (buff, len, &search, ¬);
@@ -1750,6 +1751,7 @@ static void ftrace_match_records(char *buff, int len, int enable) rec->flags &= ~flag; else rec->flags |= flag; + found =1 ; }/* * Only enable filtering if we have a function that
@@ -1759,6 +1761,8 @@ static void ftrace_match_records(char *buff, int len, int enable) ftrace_filtered =1 ; }while_for_each_ftrace_rec ();mutex_unlock (&ftrace_lock); + +return found; } static int
@@ -2151,8 +2155,10 @@ static int ftrace_process_regex(char *buff, int len, int enable) func =strsep (&next,":" );if (!next) { -ftrace_match_records (func, len, enable); -return 0 ; +if (ftrace_match_records (func, len, enable)) +return 0 ; +else +return ret; }/* command found */
Signature · 1 line
1.6.3
Re: [PATCH 2/3] ftrace: Return EINVAL when writing invalid val to set_ftrace_filter
Quoted 8 lines · Li Zefan
Currently it doesn't warn user on invald value:
# echo nonexist_symbol > set_ftrace_filterBetter make it return failure.
Signed-off-by Li Zefan <[email protected]>---
But shouldn't we have the same kind of check from ftrace_match_module_records() if we haven't matched anything with the regex?
Re: [PATCH 2/3] ftrace: Return EINVAL when writing invalid val to set_ftrace_filter
Quoted 11 lines · Frederic Weisbecker
Quoted 8 lines · Li Zefan
Currently it doesn't warn user on invald value:
# echo nonexist_symbol > set_ftrace_filterBetter make it return failure.
Signed-off-by Li Zefan <[email protected]>---
Quoted 6 lines
But shouldn't we have the same kind of check from
ftrace_match_module_records()if we haven't matched anything with the regex?
Right, I overlooked it.
Steven Rostedt
maintainerRe: [PATCH 2/3] ftrace: Return EINVAL when writing invalid val to set_ftrace_filter
Quoted 12 lines · Li Zefan
Quoted 11 lines · Frederic Weisbecker
Quoted 8 lines · Li Zefan
Currently it doesn't warn user on invald value:
# echo nonexist_symbol > set_ftrace_filterBetter make it return failure.
Signed-off-by Li Zefan <[email protected]>---
Quoted 9 lines
Quoted 6 lines
But shouldn't we have the same kind of check from
ftrace_match_module_records()if we haven't matched anything with the regex?Right, I overlooked it.
Only the first patch is urgent. I'll get that out and wait for you to update these other two (or just this one).
Thanks,
-- Steve
PATCH 3/3 function-graph: Allow writing the same val to set_graph_function
In reply to Li Zefan# echo 'do_open' > set_graph_function # echo 'do_open' >> set_graph_function bash: echo: write error: Invalid argument
Make it valid to write the same value to set_graph_function.
--- kernel/trace/ftrace.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +2 -3
@@ -2549,10 +2549,9 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer) exists = true;break ; } -if (!exists) { +if (!exists) array[(*idx)++] = rec->ip; - found =1 ; - } + found =1 ; } }while_for_each_ftrace_rec ();
Signature · 1 line
1.6.3
Quoted 4 lines · Li Zefan
# echo 'do_open : foo' > set_ftrace_filter (still holding ftrace_regex_lock when returning to user space!)Signed-off-by Li Zefan <[email protected]>
[tip:tracing/urgent] ftrace: Fix unmatched locking in ftrace_regex_write()
In reply to Li ZefanCommit-ID: ed146b25942b428f8e8056587b7638ce76573c2f Gitweb: http://git.kernel.org/tip/ed146b25942b428f8e8056587b7638ce76573c2f Author: Li Zefan <[email protected]> AuthorDate: Tue, 3 Nov 2009 08:55:38 +0800 Committer: Steven Rostedt <[email protected]> CommitDate: Wed, 4 Nov 2009 01:42:10 -0500
ftrace: Fix unmatched locking in ftrace_regex_write()
When a command is passed to the set_ftrace_filter, then the ftrace_regex_lock is still held going back to user space.
# echo 'do_open : foo' > set_ftrace_filter (still holding ftrace_regex_lock when returning to user space!)
LKML-Reference: <[email protected]>
--- kernel/trace/ftrace.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ftrace.c +3 -3
@@ -2222,15 +2222,15 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, ret =ftrace_process_regex (parser->buffer, parser->idx, enable);if (ret) - goto out; + goto out_unlock;trace_parser_clear (parser); } ret = read; - +out_unlock:mutex_unlock (&ftrace_regex_lock); -out: +return ret; }