Skip to content

Commit

Permalink
bpf: Reenable bpf_refcount_acquire
Browse files Browse the repository at this point in the history
Now that all reported issues are fixed, bpf_refcount_acquire can be
turned back on. Also reenable all bpf_refcount-related tests which were
disabled.

This a revert of:
 * commit f3514a5 ("selftests/bpf: Disable newly-added 'owner' field test until refcount re-enabled")
 * commit 7deca5e ("bpf: Disable bpf_refcount_acquire kfunc calls until race conditions are fixed")

Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20230821193311.3290257-5-davemarchevsky@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Dave Marchevsky authored and Alexei Starovoitov committed Aug 25, 2023
1 parent 7e26cd1 commit ba2464c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
5 changes: 1 addition & 4 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -11217,10 +11217,7 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_kfunc_call_
verbose(env, "arg#%d doesn't point to a type with bpf_refcount field\n", i);
return -EINVAL;
}
if (rec->refcount_off >= 0) {
verbose(env, "bpf_refcount_acquire calls are disabled for now\n");
return -EINVAL;
}

meta->arg_btf = reg->btf;
meta->arg_btf_id = reg->btf_id;
break;
Expand Down
26 changes: 26 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,38 @@

void test_refcounted_kptr(void)
{
RUN_TESTS(refcounted_kptr);
}

void test_refcounted_kptr_fail(void)
{
RUN_TESTS(refcounted_kptr_fail);
}

void test_refcounted_kptr_wrong_owner(void)
{
LIBBPF_OPTS(bpf_test_run_opts, opts,
.data_in = &pkt_v4,
.data_size_in = sizeof(pkt_v4),
.repeat = 1,
);
struct refcounted_kptr *skel;
int ret;

skel = refcounted_kptr__open_and_load();
if (!ASSERT_OK_PTR(skel, "refcounted_kptr__open_and_load"))
return;

ret = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.rbtree_wrong_owner_remove_fail_a1), &opts);
ASSERT_OK(ret, "rbtree_wrong_owner_remove_fail_a1");
ASSERT_OK(opts.retval, "rbtree_wrong_owner_remove_fail_a1 retval");

ret = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.rbtree_wrong_owner_remove_fail_b), &opts);
ASSERT_OK(ret, "rbtree_wrong_owner_remove_fail_b");
ASSERT_OK(opts.retval, "rbtree_wrong_owner_remove_fail_b retval");

ret = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.rbtree_wrong_owner_remove_fail_a2), &opts);
ASSERT_OK(ret, "rbtree_wrong_owner_remove_fail_a2");
ASSERT_OK(opts.retval, "rbtree_wrong_owner_remove_fail_a2 retval");
refcounted_kptr__destroy(skel);
}

0 comments on commit ba2464c

Please sign in to comment.