Skip to content

Commit 6350379

Browse files
Steven Rostedtrostedt
authored andcommitted
ftrace: Fix global function tracers that are not recursion safe
If one of the function tracers set by the global ops is not recursion safe, it can still be called directly without the added recursion supplied by the ftrace infrastructure. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 05cbbf6 commit 6350379

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

kernel/trace/ftrace.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,24 @@ static void update_global_ops(void)
221221
* registered callers.
222222
*/
223223
if (ftrace_global_list == &ftrace_list_end ||
224-
ftrace_global_list->next == &ftrace_list_end)
224+
ftrace_global_list->next == &ftrace_list_end) {
225225
func = ftrace_global_list->func;
226-
else
226+
/*
227+
* As we are calling the function directly.
228+
* If it does not have recursion protection,
229+
* the function_trace_op needs to be updated
230+
* accordingly.
231+
*/
232+
if (ftrace_global_list->flags & FTRACE_OPS_FL_RECURSION_SAFE)
233+
global_ops.flags |= FTRACE_OPS_FL_RECURSION_SAFE;
234+
else
235+
global_ops.flags &= ~FTRACE_OPS_FL_RECURSION_SAFE;
236+
} else {
227237
func = ftrace_global_list_func;
238+
/* The list has its own recursion protection. */
239+
global_ops.flags |= FTRACE_OPS_FL_RECURSION_SAFE;
240+
}
241+
228242

229243
/* If we filter on pids, update to use the pid function */
230244
if (!list_empty(&ftrace_pids)) {

0 commit comments

Comments
 (0)