The following commit has been merged into the x86/core branch of tip: Commit-ID: c841668784cc609e7ae103d91c3e03bf8939418d Gitweb: https://git.kernel.org/tip/c841668784cc609e7ae103d91c3e03bf8939418d Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx> AuthorDate: Fri, 11 Mar 2022 10:40:40 +01:00 Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx> CommitterDate: Fri, 11 Mar 2022 13:05:08 +01:00 x86,ftrace: Fix modify_ftrace_direct() Alexei reported that BPF direct trampolines are no longer working with IBT=y builds. Make modify_ftrace_direct() consistent vs {,un}register_ftrace_direct(), such that they all agree on where the __fentry__ site lives. Fixes: ee1a8cf8dd0f ("x86/ibt,ftrace: Search for __fentry__ location") Reported-by: Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx> Link: https://lkml.kernel.org/r/YioBZmicMj7aAlLf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --- kernel/trace/ftrace.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index ae0d9f6..8e0509e 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5381,6 +5381,11 @@ int modify_ftrace_direct(unsigned long ip, mutex_lock(&direct_mutex); mutex_lock(&ftrace_lock); + + ip = ftrace_location(ip); + if (!ip) + goto out_unlock; + entry = find_direct_entry(&ip, &rec); if (!entry) goto out_unlock;