Skip to content

Commit 3ebc98c

Browse files
olsajiriAlexei Starovoitov
authored andcommitted
ftrace: Add missing ftrace_lock to update_ftrace_direct_add/del
Ihor and Kumar reported splat from ftrace_get_addr_curr [1], which happened because of the missing ftrace_lock in update_ftrace_direct_add/del functions allowing concurrent access to ftrace internals. The ftrace_update_ops function must be guarded by ftrace_lock, adding that. Fixes: 05dc5e9 ("ftrace: Add update_ftrace_direct_add function") Fixes: 8d2c123 ("ftrace: Add update_ftrace_direct_del function") Reported-by: Ihor Solodrai <ihor.solodrai@linux.dev> Reported-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Closes: https://lore.kernel.org/bpf/1b58ffb2-92ae-433a-ba46-95294d6edea2@linux.dev/ Tested-by: Ihor Solodrai <ihor.solodrai@linux.dev> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Link: https://lore.kernel.org/r/20260302081622.165713-1-jolsa@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent af4e9ef commit 3ebc98c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

kernel/trace/ftrace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6404,6 +6404,7 @@ int update_ftrace_direct_add(struct ftrace_ops *ops, struct ftrace_hash *hash)
64046404
new_filter_hash = old_filter_hash;
64056405
}
64066406
} else {
6407+
guard(mutex)(&ftrace_lock);
64076408
err = ftrace_update_ops(ops, new_filter_hash, EMPTY_HASH);
64086409
/*
64096410
* new_filter_hash is dup-ed, so we need to release it anyway,
@@ -6530,6 +6531,7 @@ int update_ftrace_direct_del(struct ftrace_ops *ops, struct ftrace_hash *hash)
65306531
ops->func_hash->filter_hash = NULL;
65316532
}
65326533
} else {
6534+
guard(mutex)(&ftrace_lock);
65336535
err = ftrace_update_ops(ops, new_filter_hash, EMPTY_HASH);
65346536
/*
65356537
* new_filter_hash is dup-ed, so we need to release it anyway,

0 commit comments

Comments
 (0)