]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Take module reference for trampoline in module
authorJiri Olsa <jolsa@kernel.org>
Fri, 26 Mar 2021 10:59:00 +0000 (11:59 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 27 Mar 2021 02:30:11 +0000 (19:30 -0700)
commitb40a137215edc7941ca7b8c505fea84bce807633
tree79748704faea37470f54bdef1658b9505d057f86
parentbc5fec95b2314fbc810997ee86bdbe388b8f238e
bpf: Take module reference for trampoline in module

Currently module can be unloaded even if there's a trampoline
register in it. It's easily reproduced by running in parallel:

  # while :; do ./test_progs -t module_attach; done
  # while :; do rmmod bpf_testmod; sleep 0.5; done

Taking the module reference in case the trampoline's ip is
within the module code. Releasing it when the trampoline's
ip is unregistered.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210326105900.151466-1-jolsa@kernel.org
include/linux/bpf.h
kernel/bpf/trampoline.c