Message ID | 20240105000909.2818934-1-andrii@kernel.org (mailing list archive) |
---|---|
Headers | show |
Series | PTR_TO_BTF_ID arguments in global subprogs | expand |
On Thu, 2024-01-04 at 16:09 -0800, Andrii Nakryiko wrote: > This patch set follows recent changes that added btf_decl_tag-based argument > annotation support for global subprogs. This time we add ability to pass > PTR_TO_BTF_ID (BTF-aware kernel pointers) arguments into global subprograms. > We support explicitly trusted and untrusted arguments. Legacy semi-trusted > variant is not supported. > > Patches #2 through #4 do preparatory refactorings to add support for multiple > tags per argument. This is important for being able to use modifiers like > __arg_nonnull together with trusted/untrusted arguments. > > Patch #5 is adding the actual __arg_trusted and __arg_untrusted support. > > It also raises a question about default nullable vs non-nullable semantics for > PTR_TO_BTF_ID arguments. It feels like having both __arg_nonnull and > __arg_nullable would provide the best kind of experience and flexibility, but > for now we implement nullable by default semantics, as a more conservative > behavior. > > Patch #7 adds bpf_core_cast() helper macro which is a wrapper around > bpf_rdonly_cast() kfunc, but hides BTF ID manipulations behind more > user-friendly type argument instead. We utilize this macro in selftests added > in patch #8. > > Patch #8 adds a bunch of positive and negative tests to validate expected > semantics for various trusted/untrusted + nullable/non-null variants. We also > make sure that global subprog cannot destroy PTR_TO_BTF_ID, as that would > wreak havoc in caller program that is not aware of this possibility. > > There were proposals to do kernel-side type enforcement for __arg_ctx, let's > decide whether we should do that and for which program types, and I can > accommodate the logic in future revisions. > > Cc: Dave Marchevsky <davemarchevsky@meta.com> Full patch-set looks good to me. Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Hello: This series was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <ast@kernel.org>: On Thu, 4 Jan 2024 16:09:01 -0800 you wrote: > This patch set follows recent changes that added btf_decl_tag-based argument > annotation support for global subprogs. This time we add ability to pass > PTR_TO_BTF_ID (BTF-aware kernel pointers) arguments into global subprograms. > We support explicitly trusted and untrusted arguments. Legacy semi-trusted > variant is not supported. > > Patches #2 through #4 do preparatory refactorings to add support for multiple > tags per argument. This is important for being able to use modifiers like > __arg_nonnull together with trusted/untrusted arguments. > > [...] Here is the summary with links: - [bpf-next,1/8] selftests/bpf: fix test_loader check message https://git.kernel.org/bpf/bpf-next/c/7c5f9568564a - [bpf-next,2/8] bpf: make sure scalar args don't accept __arg_nonnull tag https://git.kernel.org/bpf/bpf-next/c/ca3950495684 - [bpf-next,3/8] bpf: prepare btf_prepare_func_args() for multiple tags per argument https://git.kernel.org/bpf/bpf-next/c/5436740cc03d - [bpf-next,4/8] bpf: support multiple tags per argument https://git.kernel.org/bpf/bpf-next/c/6a21d4e515f5 - [bpf-next,5/8] bpf: add __arg_trusted and __arg_untrusted global func tags (no matching commit) - [bpf-next,6/8] libbpf: add __arg_trusted and __arg_untrusted annotation macros (no matching commit) - [bpf-next,7/8] libbpf: add bpf_core_cast() macro (no matching commit) - [bpf-next,8/8] selftests/bpf: add trusted/untrusted global subprog arg tests (no matching commit) You are awesome, thank you!