]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Apr 2021 11:13:19 +0000 (13:13 +0200)
commit3071afa7a8fb0f4004981efa282106505408bee3
tree085084f4e315f1e22bafe079b369c2f3ed3e3b17
parentadaf914b7928a464ca15ae8d8cbd8e55b6b5554d
bpf: Take module reference for trampoline in module

[ Upstream commit 861de02e5f3f2a104eecc5af1d248cb7bf8c5f75 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/bpf.h
kernel/bpf/trampoline.c