mirror of https://gitee.com/openkylin/linux.git
ftrace: Fix locking in register_ftrace_function_probe()
The iteration of the ftrace function list and the call to ftrace_match_record() need to be protected by the ftrace_lock. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
da511bf33e
commit
5ae0bf5972
|
@ -3017,14 +3017,16 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
|
||||||
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
|
hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash);
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
count = -ENOMEM;
|
count = -ENOMEM;
|
||||||
goto out_unlock;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(ftrace_disabled)) {
|
if (unlikely(ftrace_disabled)) {
|
||||||
count = -ENODEV;
|
count = -ENODEV;
|
||||||
goto out_unlock;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mutex_lock(&ftrace_lock);
|
||||||
|
|
||||||
do_for_each_ftrace_rec(pg, rec) {
|
do_for_each_ftrace_rec(pg, rec) {
|
||||||
|
|
||||||
if (!ftrace_match_record(rec, NULL, search, len, type))
|
if (!ftrace_match_record(rec, NULL, search, len, type))
|
||||||
|
@ -3070,15 +3072,15 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
|
||||||
|
|
||||||
} while_for_each_ftrace_rec();
|
} while_for_each_ftrace_rec();
|
||||||
|
|
||||||
mutex_lock(&ftrace_lock);
|
|
||||||
ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash);
|
ret = ftrace_hash_move(&trace_probe_ops, 1, orig_hash, hash);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
count = ret;
|
count = ret;
|
||||||
|
|
||||||
__enable_ftrace_function_probe();
|
__enable_ftrace_function_probe();
|
||||||
mutex_unlock(&ftrace_lock);
|
|
||||||
|
|
||||||
out_unlock:
|
out_unlock:
|
||||||
|
mutex_unlock(&ftrace_lock);
|
||||||
|
out:
|
||||||
mutex_unlock(&trace_probe_ops.regex_lock);
|
mutex_unlock(&trace_probe_ops.regex_lock);
|
||||||
free_ftrace_hash(hash);
|
free_ftrace_hash(hash);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue