]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: allow passing struct bpf_iter_<type> as kfunc arguments
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 8 Aug 2024 23:22:29 +0000 (16:22 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 21 Aug 2024 17:37:52 +0000 (10:37 -0700)
commitbaebe9aaba1e59e34cd1fe6455bb4c3029ad3bc1
tree4f82bb8495a612d772caea6ea667d99fcd94bf31
parent496ddd19a0fad22f250fc7a7b7a8000155418934
bpf: allow passing struct bpf_iter_<type> as kfunc arguments

There are potentially useful cases where a specific iterator type might
need to be passed into some kfunc. So, in addition to existing
bpf_iter_<type>_{new,next,destroy}() kfuncs, allow to pass iterator
pointer to any kfunc.

We employ "__iter" naming suffix for arguments that are meant to accept
iterators. We also enforce that they accept PTR -> STRUCT btf_iter_<type>
type chain and point to a valid initialized on-the-stack iterator state.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240808232230.2848712-3-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c