Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 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
---
====================

Link: https://lore.kernel.org/r/20240905223812.141857-1-inwardvessel@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

+50
+2
kernel/bpf/btf.c
··· 8357 8357 case BPF_PROG_TYPE_STRUCT_OPS: 8358 8358 return BTF_KFUNC_HOOK_STRUCT_OPS; 8359 8359 case BPF_PROG_TYPE_TRACING: 8360 + case BPF_PROG_TYPE_TRACEPOINT: 8361 + case BPF_PROG_TYPE_PERF_EVENT: 8360 8362 case BPF_PROG_TYPE_LSM: 8361 8363 return BTF_KFUNC_HOOK_TRACING; 8362 8364 case BPF_PROG_TYPE_SYSCALL:
+48
tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c
··· 47 47 return 0; 48 48 } 49 49 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 + 50 66 /***************** 51 67 * cgroup kfuncs * 52 68 *****************/ ··· 101 85 return 0; 102 86 } 103 87 88 + SEC("tracepoint") 89 + __success 90 + int BPF_PROG(cgrp_kfunc_tracepoint) 91 + { 92 + cgrp_kfunc_load_test(); 93 + return 0; 94 + } 95 + 96 + SEC("perf_event") 97 + __success 98 + int BPF_PROG(cgrp_kfunc_perf_event) 99 + { 100 + cgrp_kfunc_load_test(); 101 + return 0; 102 + } 103 + 104 104 /****************** 105 105 * cpumask kfuncs * 106 106 ******************/ ··· 148 116 SEC("syscall") 149 117 __success 150 118 int BPF_PROG(cpumask_kfunc_syscall) 119 + { 120 + cpumask_kfunc_load_test(); 121 + return 0; 122 + } 123 + 124 + SEC("tracepoint") 125 + __success 126 + int BPF_PROG(cpumask_kfunc_tracepoint) 127 + { 128 + cpumask_kfunc_load_test(); 129 + return 0; 130 + } 131 + 132 + SEC("perf_event") 133 + __success 134 + int BPF_PROG(cpumask_kfunc_perf_event) 151 135 { 152 136 cpumask_kfunc_load_test(); 153 137 return 0;