* [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event
@ 2024-09-05 22:38 JP Kobryn
2024-09-05 22:38 ` [PATCH bpf-next v3 1/2] bpf: allow kfuncs within tracepoint and perf event programs JP Kobryn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: JP Kobryn @ 2024-09-05 22:38 UTC (permalink / raw)
To: andrii, ast, eddyz87, bpf
It is possible to call a cpumask kfunc within a raw tp_btf program but not
possible within tracepoint or perf event programs. Currently, the verifier
receives -EACCESS from fetch_kfunc_meta() as a result of not finding any
kfunc hook associated with these program types.
This patch series associates tracepoint and perf event program types with
the tracing hook and includes test coverage.
Pre-submission CI run: https://github.com/kernel-patches/bpf/pull/7674
v3:
- map tracepoint and perf event progs to tracing kfunc hook
- expand existing verifier tests for kfuncs
- remove explicit registrations from v2
- no longer including kprobes
v2:
- create new kfunc hooks for tracepoint and perf event
- map tracepoint, and perf event prog types to kfunc hooks
- register cpumask kfuncs with prog types in focus
- expand existing verifier tests for cpumask kfuncs
v1:
- map tracepoint type progs to tracing kfunc hook
- new selftests for calling cpumask kfuncs in tracepoint prog
---
JP Kobryn (2):
bpf: allow kfuncs within tracepoint and perf event programs
bpf/selftests: coverage for new program types using cpumask kfuncs
kernel/bpf/btf.c | 2 ++
.../bpf/progs/verifier_kfunc_prog_types.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+)
--
2.46.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH bpf-next v3 1/2] bpf: allow kfuncs within tracepoint and perf event programs
2024-09-05 22:38 [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event JP Kobryn
@ 2024-09-05 22:38 ` JP Kobryn
2024-09-05 22:38 ` [PATCH bpf-next v3 2/2] bpf/selftests: coverage for tp and perf event progs using kfuncs JP Kobryn
2024-09-06 0:10 ` [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: JP Kobryn @ 2024-09-05 22:38 UTC (permalink / raw)
To: andrii, ast, eddyz87, bpf
Associate tracepoint and perf event program types with the kfunc tracing
hook. This allows calling kfuncs within these types of programs.
Signed-off-by: JP Kobryn <inwardvessel@gmail.com>
---
kernel/bpf/btf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 520f49f422fe..7d25ecd195ba 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -8304,6 +8304,8 @@ static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type)
case BPF_PROG_TYPE_STRUCT_OPS:
return BTF_KFUNC_HOOK_STRUCT_OPS;
case BPF_PROG_TYPE_TRACING:
+ case BPF_PROG_TYPE_TRACEPOINT:
+ case BPF_PROG_TYPE_PERF_EVENT:
case BPF_PROG_TYPE_LSM:
return BTF_KFUNC_HOOK_TRACING;
case BPF_PROG_TYPE_SYSCALL:
--
2.46.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH bpf-next v3 2/2] bpf/selftests: coverage for tp and perf event progs using kfuncs
2024-09-05 22:38 [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event JP Kobryn
2024-09-05 22:38 ` [PATCH bpf-next v3 1/2] bpf: allow kfuncs within tracepoint and perf event programs JP Kobryn
@ 2024-09-05 22:38 ` JP Kobryn
2024-09-06 0:10 ` [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: JP Kobryn @ 2024-09-05 22:38 UTC (permalink / raw)
To: andrii, ast, eddyz87, bpf
This coverage ensures that kfuncs are allowed within tracepoint and perf
event programs.
Signed-off-by: JP Kobryn <inwardvessel@gmail.com>
---
.../bpf/progs/verifier_kfunc_prog_types.c | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c b/tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c
index cb32b0cfc84b..a509cad97e69 100644
--- a/tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c
+++ b/tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c
@@ -47,6 +47,22 @@ int BPF_PROG(task_kfunc_syscall)
return 0;
}
+SEC("tracepoint")
+__success
+int BPF_PROG(task_kfunc_tracepoint)
+{
+ task_kfunc_load_test();
+ return 0;
+}
+
+SEC("perf_event")
+__success
+int BPF_PROG(task_kfunc_perf_event)
+{
+ task_kfunc_load_test();
+ return 0;
+}
+
/*****************
* cgroup kfuncs *
*****************/
@@ -85,6 +101,22 @@ int BPF_PROG(cgrp_kfunc_syscall)
return 0;
}
+SEC("tracepoint")
+__success
+int BPF_PROG(cgrp_kfunc_tracepoint)
+{
+ cgrp_kfunc_load_test();
+ return 0;
+}
+
+SEC("perf_event")
+__success
+int BPF_PROG(cgrp_kfunc_perf_event)
+{
+ cgrp_kfunc_load_test();
+ return 0;
+}
+
/******************
* cpumask kfuncs *
******************/
@@ -120,3 +152,19 @@ int BPF_PROG(cpumask_kfunc_syscall)
cpumask_kfunc_load_test();
return 0;
}
+
+SEC("tracepoint")
+__success
+int BPF_PROG(cpumask_kfunc_tracepoint)
+{
+ cpumask_kfunc_load_test();
+ return 0;
+}
+
+SEC("perf_event")
+__success
+int BPF_PROG(cpumask_kfunc_perf_event)
+{
+ cpumask_kfunc_load_test();
+ return 0;
+}
--
2.46.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event
2024-09-05 22:38 [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event JP Kobryn
2024-09-05 22:38 ` [PATCH bpf-next v3 1/2] bpf: allow kfuncs within tracepoint and perf event programs JP Kobryn
2024-09-05 22:38 ` [PATCH bpf-next v3 2/2] bpf/selftests: coverage for tp and perf event progs using kfuncs JP Kobryn
@ 2024-09-06 0:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-06 0:10 UTC (permalink / raw)
To: JP Kobryn; +Cc: andrii, ast, eddyz87, bpf
Hello:
This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Thu, 5 Sep 2024 15:38:10 -0700 you wrote:
> It is possible to call a cpumask kfunc within a raw tp_btf program but not
> possible within tracepoint or perf event programs. Currently, the verifier
> receives -EACCESS from fetch_kfunc_meta() as a result of not finding any
> kfunc hook associated with these program types.
>
> This patch series associates tracepoint and perf event program types with
> the tracing hook and includes test coverage.
>
> [...]
Here is the summary with links:
- [bpf-next,v3,1/2] bpf: allow kfuncs within tracepoint and perf event programs
https://git.kernel.org/bpf/bpf-next/c/bc638d8cb5be
- [bpf-next,v3,2/2] bpf/selftests: coverage for tp and perf event progs using kfuncs
https://git.kernel.org/bpf/bpf-next/c/1b3bc648f506
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-06 0:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 22:38 [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event JP Kobryn
2024-09-05 22:38 ` [PATCH bpf-next v3 1/2] bpf: allow kfuncs within tracepoint and perf event programs JP Kobryn
2024-09-05 22:38 ` [PATCH bpf-next v3 2/2] bpf/selftests: coverage for tp and perf event progs using kfuncs JP Kobryn
2024-09-06 0:10 ` [PATCH bpf-next v3 0/2] allow kfuncs in tracepoint and perf event patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox