diff mbox series

[bpf-next,2/4] bpf: Enable BPF_PROG_TEST_RUN for tp_btf

Message ID 20250426160027.177173-3-mannkafai@gmail.com
State New
Headers show
Series bpf: Allow get_func_[arg|arg_cnt] helpers in raw tracepoint programs | expand

Commit Message

KaFai Wan April 26, 2025, 4 p.m. UTC
Add .test_run for tp_btf. Use the .test_run for raw_tp.

Signed-off-by: KaFai Wan <mannkafai@gmail.com>
---
 net/bpf/test_run.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Andrii Nakryiko May 1, 2025, 8:55 p.m. UTC | #1
On Sat, Apr 26, 2025 at 9:01 AM KaFai Wan <mannkafai@gmail.com> wrote:
>
> Add .test_run for tp_btf. Use the .test_run for raw_tp.

Hm... so now you'll be able to pass arbitrary values as pointers to
kernel structs (e.g., arbitrary u64 as struct task_struct * pointer),
not sure this is a good idea...

>
> Signed-off-by: KaFai Wan <mannkafai@gmail.com>
> ---
>  net/bpf/test_run.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index 8cb285187270..8c901ec92341 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -690,6 +690,9 @@ int bpf_prog_test_run_tracing(struct bpf_prog *prog,
>         int b = 2, err = -EFAULT;
>         u32 retval = 0;
>
> +       if (prog->expected_attach_type == BPF_TRACE_RAW_TP)
> +               return bpf_prog_test_run_raw_tp(prog, kattr, uattr);
> +
>         if (kattr->test.flags || kattr->test.cpu || kattr->test.batch_size)
>                 return -EINVAL;
>
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 8cb285187270..8c901ec92341 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -690,6 +690,9 @@  int bpf_prog_test_run_tracing(struct bpf_prog *prog,
 	int b = 2, err = -EFAULT;
 	u32 retval = 0;
 
+	if (prog->expected_attach_type == BPF_TRACE_RAW_TP)
+		return bpf_prog_test_run_raw_tp(prog, kattr, uattr);
+
 	if (kattr->test.flags || kattr->test.cpu || kattr->test.batch_size)
 		return -EINVAL;