Skip to content

Commit 04bb60d

Browse files
author
Alexei Starovoitov
committed
Merge branch 'allow-kfuncs-in-tracepoint-and-perf-event'
JP Kobryn says: ==================== allow kfuncs in tracepoint and perf event 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: #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 --- ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
2 parents 2db2b8c + 1b3bc64 commit 04bb60d

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

kernel/bpf/btf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8357,6 +8357,8 @@ static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type)
83578357
case BPF_PROG_TYPE_STRUCT_OPS:
83588358
return BTF_KFUNC_HOOK_STRUCT_OPS;
83598359
case BPF_PROG_TYPE_TRACING:
8360+
case BPF_PROG_TYPE_TRACEPOINT:
8361+
case BPF_PROG_TYPE_PERF_EVENT:
83608362
case BPF_PROG_TYPE_LSM:
83618363
return BTF_KFUNC_HOOK_TRACING;
83628364
case BPF_PROG_TYPE_SYSCALL:

tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ int BPF_PROG(task_kfunc_syscall)
4747
return 0;
4848
}
4949

50+
SEC("tracepoint")
51+
__success
52+
int BPF_PROG(task_kfunc_tracepoint)
53+
{
54+
task_kfunc_load_test();
55+
return 0;
56+
}
57+
58+
SEC("perf_event")
59+
__success
60+
int BPF_PROG(task_kfunc_perf_event)
61+
{
62+
task_kfunc_load_test();
63+
return 0;
64+
}
65+
5066
/*****************
5167
* cgroup kfuncs *
5268
*****************/
@@ -85,6 +101,22 @@ int BPF_PROG(cgrp_kfunc_syscall)
85101
return 0;
86102
}
87103

104+
SEC("tracepoint")
105+
__success
106+
int BPF_PROG(cgrp_kfunc_tracepoint)
107+
{
108+
cgrp_kfunc_load_test();
109+
return 0;
110+
}
111+
112+
SEC("perf_event")
113+
__success
114+
int BPF_PROG(cgrp_kfunc_perf_event)
115+
{
116+
cgrp_kfunc_load_test();
117+
return 0;
118+
}
119+
88120
/******************
89121
* cpumask kfuncs *
90122
******************/
@@ -120,3 +152,19 @@ int BPF_PROG(cpumask_kfunc_syscall)
120152
cpumask_kfunc_load_test();
121153
return 0;
122154
}
155+
156+
SEC("tracepoint")
157+
__success
158+
int BPF_PROG(cpumask_kfunc_tracepoint)
159+
{
160+
cpumask_kfunc_load_test();
161+
return 0;
162+
}
163+
164+
SEC("perf_event")
165+
__success
166+
int BPF_PROG(cpumask_kfunc_perf_event)
167+
{
168+
cpumask_kfunc_load_test();
169+
return 0;
170+
}

0 commit comments

Comments
 (0)