bpf: allow calling kfuncs from raw_tp programs
Subsystems (3)
PATCH 1/1 bpf: allow calling kfuncs from raw_tp programs
Associate raw tracepoint program type with the kfunc tracing hook. This allows calling kfuncs from raw_tp programs.
Signed-off-by Puranjay Mohan <[email protected]>
--- kernel/bpf/btf.c | 1 + 1 file changed, 1 insertion(+)
kernel/bpf/btf.c +1 -0
@@ -8681,6 +8681,7 @@ static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type)return BTF_KFUNC_HOOK_STRUCT_OPS ;case BPF_PROG_TYPE_TRACING :case BPF_PROG_TYPE_TRACEPOINT : +case BPF_PROG_TYPE_RAW_TRACEPOINT :case BPF_PROG_TYPE_PERF_EVENT :case BPF_PROG_TYPE_LSM :return BTF_KFUNC_HOOK_TRACING ;
base-commit: ec439c38013550420aecc15988ae6acb670838c1
Signature · 1 line
2.47.3
Yonghong Song
reviewerQuoted 13 lines · Puranjay Mohan
Associate raw tracepoint program type with the kfunc tracing hook. This allows calling kfuncs from
raw_tpprograms.Signed-off-by Puranjay Mohan <[email protected]>--- kernel/bpf/btf.c | 1 + 1 file changed, 1 insertion(+)kernel/bpf/btf.c +0
-0
kernel/bpf/btf.c static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type) · line 8684
Quoted 4 lines
kernel/bpf/btf.c +1
-0@@ -8681,6 +8681,7 @@ static int bpf_prog_type_to_kfunc_hook(enum bpf_prog_type prog_type)return BTF_KFUNC_HOOK_STRUCT_OPS ;case BPF_PROG_TYPE_TRACING :case BPF_PROG_TYPE_TRACEPOINT : +case BPF_PROG_TYPE_RAW_TRACEPOINT :
You need to fix the selftest progs/verifier_kfunc_prog_types.c like below:
tools/testing/selftests/bpf/progs/verifier_kfunc_prog_types.c +3 -3
@@ -32,7 +32,7 @@ static void task_kfunc_load_test(void) } SEC("raw_tp") -__failure __msg("calling kernel function") +__successint BPF_PROG (task_kfunc_raw_tp ) {task_kfunc_load_test ();
@@ -86,7 +86,7 @@ static void cgrp_kfunc_load_test(void) } SEC("raw_tp") -__failure __msg("calling kernel function") +__successint BPF_PROG (cgrp_kfunc_raw_tp ) {cgrp_kfunc_load_test ();
@@ -138,7 +138,7 @@ static void cpumask_kfunc_load_test(void) } SEC("raw_tp") -__failure __msg("calling kernel function") +__successint BPF_PROG (cpumask_kfunc_raw_tp ) {cpumask_kfunc_load_test ();
Quoted 5 lines
kernel/bpf/btf.c +0
-0case BPF_PROG_TYPE_PERF_EVENT :case BPF_PROG_TYPE_LSM :return BTF_KFUNC_HOOK_TRACING ;base-commit:
ec439c38013550420aecc15988ae6acb670838c1