Repository navigation
Conversation
The base group was missing helpers that bpf_base_func_proto() has
handed out to every program type for a while:
- bpf_strtol, bpf_strtoul since v6.1 (commit 8a67f2de9b1d, "bpf: expose
bpf_strtol and bpf_strtoul to all program types")
- bpf_perf_event_read_value since v6.15 (commit ae0a457f5d33)
- bpf_get_current_uid_gid, bpf_current_task_under_cgroup,
bpf_get_cgroup_classid, bpf_task_storage_{get,delete},
bpf_get_current_comm, bpf_perf_event_read, bpf_send_signal{,_thread},
bpf_get_task_stack, bpf_get_branch_snapshot and bpf_find_vma since
v6.16 (commit ee971630f20f, "bpf: Allow some trace helpers for all
prog types")
Capabilities and kconfig follow the sections of bpf_base_func_proto()
they sit in. bpf_copy_from_user and bpf_copy_from_user_task were moved
to the base set by the same v6.16 commit but are left out: they are
might_sleep helpers and the verifier rejects them in non-sleepable
programs. Of the program types that use the base group, only struct_ops
can be sleepable, so listing them in base would mostly document helpers
that can't be called. bpftool feature probe does list them for XDP, TC
and friends, because its heuristic treats "helper call might sleep in a
non-sleepable prog" as supported.
Program type and helper pages regenerated with tools/helper-ref-gen.
Signed-off-by: YoungjuKim <fjvbn2003@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
basegroup indata/helpers-functions.yamlmirrorsbpf_base_func_proto(), but it is missing helpers that the kernel has handed to every program type for a while. For example, thebpf_get_current_commpage lists only tracing, LSM, syscall and cgroup sock types, while XDP and TC programs can call it since v6.16.Added to
base, withsinceset to the commit that moved each helper intobpf_base_func_proto():bpf_strtol,bpf_strtoul: v6.1, 8a67f2de9b1d ("bpf: expose bpf_strtol and bpf_strtoul to all program types")bpf_perf_event_read_value: v6.15, ae0a457f5d33bpf_get_current_uid_gid,bpf_current_task_under_cgroup,bpf_get_cgroup_classid,bpf_task_storage_get,bpf_task_storage_delete,bpf_get_current_comm,bpf_perf_event_read,bpf_send_signal,bpf_send_signal_thread,bpf_get_task_stack,bpf_get_branch_snapshot,bpf_find_vma: v6.16, ee971630f20f ("bpf: Allow some trace helpers for all prog types")capandkconfigfollow the section ofbpf_base_func_proto()each helper is in (no capability,CAP_BPF, orCAP_BPF+CAP_PERFMON;CONFIG_CGROUPS/CONFIG_CGROUP_NET_CLASSID). Program types that already list one of these helpers keep their own entry, because the generator lets a parent definition override the base one.I left out
bpf_copy_from_userandbpf_copy_from_user_task. The same v6.16 commit added them to the base set, but they aremight_sleephelpers, and the verifier rejects them in non-sleepable programs ("helper call might sleep in a non-sleepable prog"). Of the program types that use the base group, only struct_ops can be sleepable. I can add them forBPF_PROG_TYPE_STRUCT_OPSonly if you prefer.The program type and helper pages were regenerated with
tools/helper-ref-gen(built from this repo). No other generated files changed.How I checked it:
bpftool feature probe(bpftool v7.7.0 / libbpf 1.7) on Ubuntu 25.04 (6.14.0-37-generic) and Ubuntu 26.04 (7.0.0-38-generic). On 7.0, the v6.15/v6.16 helpers above show up for socket_filter, sched_cls, sched_act, xdp, cgroup_skb, lwt_*, sock_ops, sk_skb, sk_msg, flow_dissector, sk_reuseport, sk_lookup and netfilter (where the type didn't already have them). On 6.14 they don't.bpf_strtol/bpf_strtoulshow up on both kernels.bpf_copy_from_userfor XDP etc. on 7.0. That is because its heuristic treats any verifier error other than "unknown func" / "cannot use helper" as supported.This change was drafted with AI assistance and reviewed by me.
🤖 Generated with Claude Code