bpf: Take module reference on kprobe_multi link
authorJiri Olsa <jolsa@kernel.org>
Tue, 25 Oct 2022 13:41:44 +0000 (15:41 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Oct 2022 17:14:51 +0000 (10:14 -0700)
commite22061b2d3095c12f90336479f24bf5eeb70e1bd
treecb0ec4b822236b0420acf25609b21f0202767cc9
parent1a1b0716d36d21f8448bd7d3f1c0ade7230bb294
bpf: Take module reference on kprobe_multi link

Currently we allow to create kprobe multi link on function from kernel
module, but we don't take the module reference to ensure it's not
unloaded while we are tracing it.

The multi kprobe link is based on fprobe/ftrace layer which takes
different approach and releases ftrace hooks when module is unloaded
even if there's tracer registered on top of it.

Adding code that gathers all the related modules for the link and takes
their references before it's attached. All kernel module references are
released after link is unregistered.

Note that we do it the same way already for trampoline probes
(but for single address).

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20221025134148.3300700-5-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/trace/bpf_trace.c