]> git.baikalelectronics.ru Git - kernel.git/commit
ftrace: Fix modify_ftrace_direct.
authorAlexei Starovoitov <ast@kernel.org>
Tue, 16 Mar 2021 19:58:15 +0000 (12:58 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 16 Mar 2021 23:43:12 +0000 (00:43 +0100)
commit8a141dd7f7060d1e64c14a5257e0babae20ac99b
tree8d58ea8dffd5a052b0a3c71f87ec20c7bede9e95
parent31254dc9566221429d2cfb45fd5737985d70f2b6
ftrace: Fix modify_ftrace_direct.

The following sequence of commands:
  register_ftrace_direct(ip, addr1);
  modify_ftrace_direct(ip, addr1, addr2);
  unregister_ftrace_direct(ip, addr2);
will cause the kernel to warn:
[   30.179191] WARNING: CPU: 2 PID: 1961 at kernel/trace/ftrace.c:5223 unregister_ftrace_direct+0x130/0x150
[   30.180556] CPU: 2 PID: 1961 Comm: test_progs    W  O      5.12.0-rc2-00378-g86bc10a0a711-dirty #3246
[   30.182453] RIP: 0010:unregister_ftrace_direct+0x130/0x150

When modify_ftrace_direct() changes the addr from old to new it should update
the addr stored in ftrace_direct_funcs. Otherwise the final
unregister_ftrace_direct() won't find the address and will cause the splat.

Fixes: 0567d6809182 ("ftrace: Add modify_ftrace_direct()")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/bpf/20210316195815.34714-1-alexei.starovoitov@gmail.com
kernel/trace/ftrace.c