]> git.baikalelectronics.ru Git - kernel.git/commit
rethook: Reject getting a rethook if RCU is not watching
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Tue, 7 Jun 2022 16:11:12 +0000 (01:11 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 17 Jun 2022 19:53:35 +0000 (21:53 +0200)
commit07bc8cfb53aa4823c0aacc5fa49f5e340fd60729
tree3a8b879d974634df53f0777bc000184cd21590a7
parente5d909a72c0ba5e40f8b4a43a51c9452970b2ff3
rethook: Reject getting a rethook if RCU is not watching

Since the rethook_recycle() will involve the call_rcu() for reclaiming
the rethook_instance, the rethook must be set up at the RCU available
context (non idle). This rethook_recycle() in the rethook trampoline
handler is inevitable, thus the RCU available check must be done before
setting the rethook trampoline.

This adds a rcu_is_watching() check in the rethook_try_get() so that
it will return NULL if it is called when !rcu_is_watching().

Fixes: 2e385b6f172e ("rethook: Add a generic return hook")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/165461827269.280167.7379263615545598958.stgit@devnote2
kernel/trace/rethook.c