bpf: Streamline allowed helpers between tracing and base sets
authorFeng Yang <yangfeng@kylinos.cn>
Wed, 23 Apr 2025 07:31:51 +0000 (15:31 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 23 Apr 2025 17:52:16 +0000 (10:52 -0700)
commit6aca583f90b0eb159cfd79c1b7f28d7c0108aed6
tree4e84f7dbeea8c2f9477d72b81ee10d8140065303
parent53ebef53a657d7957d35dc2b953db64f1bb28065
bpf: Streamline allowed helpers between tracing and base sets

Many conditional checks in switch-case are redundant
with bpf_base_func_proto and should be removed.

Regarding the permission checks bpf_base_func_proto:
The permission checks in bpf_prog_load (as outlined below)
ensure that the trace has both CAP_BPF and CAP_PERFMON capabilities,
thus enabling the use of corresponding prototypes
in bpf_base_func_proto without adverse effects.
bpf_prog_load
......
bpf_cap = bpf_token_capable(token, CAP_BPF);
......
if (type != BPF_PROG_TYPE_SOCKET_FILTER &&
    type != BPF_PROG_TYPE_CGROUP_SKB &&
    !bpf_cap)
goto put_token;
......
if (is_perfmon_prog_type(type) && !bpf_token_capable(token, CAP_PERFMON))
goto put_token;
......

Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/bpf/20250423073151.297103-1-yangfeng59949@163.com
kernel/trace/bpf_trace.c