[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <455a554d-fe8f-4c9e-b1d9-654897da92ce@linux.dev>
Date: Tue, 17 Dec 2024 17:17:27 -0800
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Amery Hung <amery.hung@...edance.com>
Cc: bpf@...r.kernel.org, netdev@...r.kernel.org, daniel@...earbox.net,
andrii@...nel.org, alexei.starovoitov@...il.com, martin.lau@...nel.org,
sinquersw@...il.com, toke@...hat.com, jhs@...atatu.com, jiri@...nulli.us,
stfomichev@...il.com, ekarani.silvestre@....ufcg.edu.br,
yangpeihao@...u.edu.cn, xiyou.wangcong@...il.com, yepeilin.cs@...il.com,
ameryhung@...il.com
Subject: Re: [PATCH bpf-next v1 02/13] selftests/bpf: Test referenced kptr
arguments of struct_ops programs
On 12/13/24 3:29 PM, Amery Hung wrote:
> +void test_struct_ops_refcounted(void)
> +{
> + if (test__start_subtest("refcounted"))
> + refcounted();
> + if (test__start_subtest("refcounted_fail__ref_leak"))
> + refcounted_fail__ref_leak();
test_loader.c could make writing this test easier and it can also test the
verifier failure message. e.g. for the ref_leak test, the following should do:
RUN_TESTS(struct_ops_refcounted_fail__ref_leak);
The same for the other subtests in this patch.
> + if (test__start_subtest("refcounted_fail__global_subprog"))
> + refcounted_fail__global_subprog();
> +}
[ ... ]
> diff --git a/tools/testing/selftests/bpf/progs/struct_ops_refcounted_fail__ref_leak.c b/tools/testing/selftests/bpf/progs/struct_ops_refcounted_fail__ref_leak.c
> new file mode 100644
> index 000000000000..6e82859eb187
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/struct_ops_refcounted_fail__ref_leak.c
> @@ -0,0 +1,17 @@
> +#include <vmlinux.h>
> +#include <bpf/bpf_tracing.h>
> +#include "../bpf_testmod/bpf_testmod.h"
> +
> +char _license[] SEC("license") = "GPL";
> +
+#include "bpf_misc.h"
+__failure __msg("Unreleased reference")
> +SEC("struct_ops/test_refcounted")
> +int BPF_PROG(test_refcounted, int dummy,
> + struct task_struct *task)
> +{
> + return 0;
> +}
> +
> +SEC(".struct_ops.link")
> +struct bpf_testmod_ops testmod_ref_acquire = {
> + .test_refcounted = (void *)test_refcounted,
> +};
[ I will stop here for today and will continue the rest tomorrow. ]
Powered by blists - more mailing lists