-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trusted PTR_TO_BTF_ID arg support in global subprogs #6323
Conversation
Upstream branch: c8632ac |
4dbeb3c
to
6ea00cf
Compare
Upstream branch: be4840b |
6c5ccfd
to
b6cd72d
Compare
6ea00cf
to
93efb90
Compare
Upstream branch: e6be8cd |
b6cd72d
to
de30ef1
Compare
93efb90
to
5e6b2a7
Compare
Upstream branch: e6be8cd |
de30ef1
to
3ec9d7c
Compare
5e6b2a7
to
3fc2b3b
Compare
Upstream branch: e48f0f4 |
3ec9d7c
to
ffe94c1
Compare
3fc2b3b
to
af8b2c1
Compare
Upstream branch: fa7178b |
ffe94c1
to
593b7ea
Compare
af8b2c1
to
730c81a
Compare
Upstream branch: beb53f3 |
593b7ea
to
998304d
Compare
730c81a
to
c5809f0
Compare
Upstream branch: 29788f3 |
998304d
to
62d43c7
Compare
c5809f0
to
ee82933
Compare
Upstream branch: 06a33d0 |
62d43c7
to
03fc3a0
Compare
ee82933
to
b6b4cf1
Compare
Upstream branch: f149d03 |
03fc3a0
to
50d2052
Compare
b6b4cf1
to
7a38734
Compare
Upstream branch: efaa47d |
50d2052
to
de339ff
Compare
7a38734
to
c8febc5
Compare
Now that feature detection code is in bpf-next tree, integrate __arg_ctx kernel-side support into kernel_supports() framework. Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Adjust PERF_EVENT type enforcement around __arg_ctx to match exactly what kernel is doing. Fixes: 76ec90a ("libbpf: warn on unexpected __arg_ctx type when rewriting BTF") Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Now that bpf and bpf-next trees converged and we don't run the risk of merge conflicts, move btf_validate_prog_ctx_type() into its most logical place inside the main logic loop. Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Add support for passing PTR_TO_BTF_ID registers to global subprogs. Currently only PTR_TRUSTED flavor of PTR_TO_BTF_ID is supported. Non-NULL semantics is assumed, so caller will be forced to prove PTR_TO_BTF_ID can't be NULL. Note, we disallow global subprogs to destroy passed in PTR_TO_BTF_ID arguments, even the trusted one. We achieve that by not setting ref_obj_id when validating subprog code. This basically enforces (in Rust terms) borrowing semantics vs move semantics. Borrowing semantics seems to be a better fit for isolated global subprog validation approach. Implementation-wise, we utilize existing logic for matching user-provided BTF type to kernel-side BTF type, used by BPF CO-RE logic and following same matching rules. We enforce a unique match for types. Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Add ability to mark arg:trusted arguments with optional arg:maybe_null tag to mark is as PTR_TO_BTF_ID_OR_NULL variant, which will allow callers to pass NULL, and subsequently will force global subprog's code to do NULL check. This allows to have "optional" PTR_TO_BTF_ID values passed into global subprogs. For now arg:maybe_null cannot be combined with anything else. Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Add __arg_trusted to annotate global func args that accept trusted PTR_TO_BTF_ID arguments. Also add __arg_maybe_null to combine with __arg_trusted (and maybe other tags in the future) to force global subprog itself (i.e., callee) to do NULL checks, as opposed to default non-NULL semantics (and thus caller's responsibility to ensure non-NULL values). Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Add a bunch of test cases validating behavior of __arg_trusted and its combination with __arg_maybe_null tag. We also validate CO-RE flavor support by kernel for __arg_trusted args. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Upstream branch: ced33f2 |
de339ff
to
a3ac3dc
Compare
05df406
to
1bc9ceb
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=820027 irrelevant now. Closing PR. |
Pull request for series with
subject: Trusted PTR_TO_BTF_ID arg support in global subprogs
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=820027