rethook: Use __rcu pointer for rethook::handler
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Fri, 1 Dec 2023 05:53:56 +0000 (14:53 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Fri, 1 Dec 2023 05:53:56 +0000 (14:53 +0900)
commita1461f1fd6cfdc4b8917c9d4a91e92605d1f28dc
treecaed8315567be58b912560043e4dde9fe3214940
parentd839a656d0f3caca9f96e9bf912fd394ac6a11bc
rethook: Use __rcu pointer for rethook::handler

Since the rethook::handler is an RCU-maganged pointer so that it will
notice readers the rethook is stopped (unregistered) or not, it should
be an __rcu pointer and use appropriate functions to be accessed. This
will use appropriate memory barrier when accessing it. OTOH,
rethook::data is never changed, so we don't need to check it in
get_kretprobe().

NOTE: To avoid sparse warning, rethook::handler is defined by a raw
function pointer type with __rcu instead of rethook_handler_t.

Link: https://lore.kernel.org/all/170126066201.398836.837498688669005979.stgit@devnote2/
Fixes: 54ecbe6f1ed5 ("rethook: Add a generic return hook")
Cc: stable@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311241808.rv9ceuAh-lkp@intel.com/
Tested-by: JP Kobryn <inwardvessel@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
include/linux/kprobes.h
include/linux/rethook.h
kernel/trace/rethook.c