diff options
author | Artem Savkov <asavkov@redhat.com> | 2022-08-10 09:59:05 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-08-10 19:22:18 +0300 |
commit | e338945816754a1c362f606b8e2029f2c023e51c (patch) | |
tree | 64d658b00f4c229d96a974e1dc0b40a0e4203e9f /net | |
parent | 133790596406ce2658f0864eb7eac64987c2b12f (diff) | |
download | linux-e338945816754a1c362f606b8e2029f2c023e51c.tar.xz |
selftests/bpf: add destructive kfunc test
Add a test checking that programs calling destructive kfuncs can only do
so if they have CAP_SYS_BOOT capabilities.
Signed-off-by: Artem Savkov <asavkov@redhat.com>
Link: https://lore.kernel.org/r/20220810065905.475418-4-asavkov@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bpf/test_run.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index cbc9cd5058cb..afa7125252f6 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -695,6 +695,10 @@ noinline void bpf_kfunc_call_test_ref(struct prog_test_ref_kfunc *p) { } +noinline void bpf_kfunc_call_test_destructive(void) +{ +} + __diag_pop(); ALLOW_ERROR_INJECTION(bpf_modify_return_test, ERRNO); @@ -719,6 +723,7 @@ BTF_ID_FLAGS(func, bpf_kfunc_call_test_mem_len_pass1) BTF_ID_FLAGS(func, bpf_kfunc_call_test_mem_len_fail1) BTF_ID_FLAGS(func, bpf_kfunc_call_test_mem_len_fail2) BTF_ID_FLAGS(func, bpf_kfunc_call_test_ref, KF_TRUSTED_ARGS) +BTF_ID_FLAGS(func, bpf_kfunc_call_test_destructive, KF_DESTRUCTIVE) BTF_SET8_END(test_sk_check_kfunc_ids) static void *bpf_test_init(const union bpf_attr *kattr, u32 user_size, |