提交 59338f75 编写于 作者: S Steven Rostedt (Red Hat) 提交者: Steven Rostedt

ftrace: Fix a slight race in modifying what function callback gets traced

There's a slight race when going from a list function to a non list
function. That is, when only one callback is registered to the function
tracer, it gets called directly by the mcount trampoline. But if this
function has filters, it may be called by the wrong functions.

As the list ops callback that handles multiple callbacks that are
registered to ftrace, it also handles what functions they call. While
the transaction is taking place, use the list function always, and
after all the updates are finished (only the functions that should be
traced are being traced), then we can update the trampoline to call
the function directly.
Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
上级 ccfe9e42
...@@ -1978,12 +1978,27 @@ int __weak ftrace_arch_code_modify_post_process(void) ...@@ -1978,12 +1978,27 @@ int __weak ftrace_arch_code_modify_post_process(void)
void ftrace_modify_all_code(int command) void ftrace_modify_all_code(int command)
{ {
int update = command & FTRACE_UPDATE_TRACE_FUNC;
/*
* If the ftrace_caller calls a ftrace_ops func directly,
* we need to make sure that it only traces functions it
* expects to trace. When doing the switch of functions,
* we need to update to the ftrace_ops_list_func first
* before the transition between old and new calls are set,
* as the ftrace_ops_list_func will check the ops hashes
* to make sure the ops are having the right functions
* traced.
*/
if (update)
ftrace_update_ftrace_func(ftrace_ops_list_func);
if (command & FTRACE_UPDATE_CALLS) if (command & FTRACE_UPDATE_CALLS)
ftrace_replace_code(1); ftrace_replace_code(1);
else if (command & FTRACE_DISABLE_CALLS) else if (command & FTRACE_DISABLE_CALLS)
ftrace_replace_code(0); ftrace_replace_code(0);
if (command & FTRACE_UPDATE_TRACE_FUNC) if (update && ftrace_trace_function != ftrace_ops_list_func)
ftrace_update_ftrace_func(ftrace_trace_function); ftrace_update_ftrace_func(ftrace_trace_function);
if (command & FTRACE_START_FUNC_RET) if (command & FTRACE_START_FUNC_RET)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册