diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2021-10-02 06:47:57 +0530 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-10-05 17:07:42 -0700 |
commit | c48e51c8b07aba8a18125221cb67a40cb1256bf2 (patch) | |
tree | be96b11f4bdd8494e6c1f2f44fcb7a725237ecc4 /net | |
parent | 18f4fccbf314fdb07d276f4cd3eaf53f1825550d (diff) | |
download | linux-stable-c48e51c8b07aba8a18125221cb67a40cb1256bf2.tar.gz linux-stable-c48e51c8b07aba8a18125221cb67a40cb1256bf2.tar.bz2 linux-stable-c48e51c8b07aba8a18125221cb67a40cb1256bf2.zip |
bpf: selftests: Add selftests for module kfunc support
This adds selftests that tests the success and failure path for modules
kfuncs (in presence of invalid kfunc calls) for both libbpf and
gen_loader. It also adds a prog_test kfunc_btf_id_list so that we can
add module BTF ID set from bpf_testmod.
This also introduces a couple of test cases to verifier selftests for
validating whether we get an error or not depending on if invalid kfunc
call remains after elimination of unreachable instructions.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211002011757.311265-10-memxor@gmail.com
Diffstat (limited to 'net')
-rw-r--r-- | net/bpf/test_run.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index b1f6f5237de6..529608784aa8 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -2,6 +2,7 @@ /* Copyright (c) 2017 Facebook */ #include <linux/bpf.h> +#include <linux/btf.h> #include <linux/btf_ids.h> #include <linux/slab.h> #include <linux/vmalloc.h> @@ -243,7 +244,9 @@ BTF_SET_END(test_sk_kfunc_ids) bool bpf_prog_test_check_kfunc_call(u32 kfunc_id, struct module *owner) { - return btf_id_set_contains(&test_sk_kfunc_ids, kfunc_id); + if (btf_id_set_contains(&test_sk_kfunc_ids, kfunc_id)) + return true; + return bpf_check_mod_kfunc_call(&prog_test_kfunc_list, kfunc_id, owner); } static void *bpf_test_init(const union bpf_attr *kattr, u32 size, |