Skip to content

bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS#11468

Closed
kernel-patches-daemon-bpf[bot] wants to merge 3 commits intobpf-next_basefrom
series/1068916=>bpf-next
Closed

bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS#11468
kernel-patches-daemon-bpf[bot] wants to merge 3 commits intobpf-next_basefrom
series/1068916=>bpf-next

Conversation

@kernel-patches-daemon-bpf
Copy link
Copy Markdown

Pull request for series with
subject: bpf: Support struct btf_struct_meta via KF_IMPLICIT_ARGS
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 77378da
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916
version: 3

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 888329b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916
version: 3

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 4a4fedb
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916
version: 3

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 350de5b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916
version: 3

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 4b21ea5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916
version: 3

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 4b21ea5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916
version: 3

@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

Upstream branch: 21337b5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916
version: 3

theihor added 2 commits March 21, 2026 13:16
The following kfuncs currently accept void *meta__ign argument:
  * bpf_obj_new_impl
  * bpf_obj_drop_impl
  * bpf_percpu_obj_new_impl
  * bpf_percpu_obj_drop_impl
  * bpf_refcount_acquire_impl
  * bpf_list_push_front_impl
  * bpf_rbtree_add_impl

The __ign suffix is an indicator for the verifier to skip the argument
in check_kfunc_args(). Then, in fixup_kfunc_call() the verifier may
set the value of this argument to struct btf_struct_meta *
kptr_struct_meta from insn_aux_data.

BPF programs must pass a dummy NULL value when caling these kfuncs.

Additionally, the list and rbtree _impl kfuncs also accept an implicit
u64 argument, which doesn't require __ign suffix because it's a
scalar, and BPF programs explicitly pass 0.

Add new kfuncs with KF_IMPLICIT_ARGS [1], that correspond to each
_impl kfunc accepting meta__ign. The existing _impl kfuncs remain
unchanged for backwards compatibility.

To support this, add "btf_struct_meta" to the list of recognized
implicit argument types in resolve_btfids.

Implement is_kfunc_arg_implicit() in the verifier, that determines
implicit args by inspecting both (_impl and non-_impl) BTF prototypes
of the kfunc.

Update the special_kfunc_list in the verifier and relevant checks to
support both the old _impl and the new KF_IMPLICIT_ARGS variants of
btf_struct_meta users.

[1] https://lore.kernel.org/bpf/20260120222638.3976562-1-ihor.solodrai@linux.dev/

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Update selftests to use the new non-_impl kfuncs marked with
KF_IMPLICIT_ARGS by removing redundant declarations and macros from
bpf_experimental.h (the new kfuncs are present in the vmlinux.h) and
updating relevant callsites.

Fix spin_lock verifier-log matching for lock_id_kptr_preserve by
accepting variable instruction numbers. The calls to kfuncs with
implicit arguments do not have register moves (e.g. r5 = 0)
corresponding to dummy arguments anymore, so the order of instructions
has shifted.

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Acked-by: Mykyta Yatsenko <yatsenko@meta.com>
@kernel-patches-daemon-bpf
Copy link
Copy Markdown
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1068916 expired. Closing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant