From: Andrii Nakryiko <andrii@kernel.org>
To: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
martin.lau@kernel.org
Cc: andrii@kernel.org, kernel-team@meta.com
Subject: [PATCH v2 bpf-next 0/7] Trusted PTR_TO_BTF_ID arg support in global subprogs
Date: Thu, 25 Jan 2024 12:55:03 -0800 [thread overview]
Message-ID: <20240125205510.3642094-1-andrii@kernel.org> (raw)
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 arguments only, for now.
First three patches are preparatory. Patches #1 and #3 does post-BPF token
code adjustments, to undo merge conflict avoidance measures. Patch #2 makes
PERF_EVENT type enforcement logic aligned with kernel-side logic.
Patch #4 adds logic for arg:trusted tag support on the verifier side. Default
semantic of such arguments is non-NULL, enforced on caller side. But patch #5
adds arg:maybe_null tag that can be combined with arg:trusted to make callee
explicitly do the NULL check, which helps implement "optional" PTR_TO_BTF_ID
arguments.
Patch #6 adds libbpf-side __arg_trusted and __arg_maybe_null macros. Patch #7
adds a bunch of tests validating __arg_trusted in combination with
__arg_maybe_null.
v1->v2:
- added fix up to type enforcement changes, landed earlier;
- dropped bpf_core_cast() changes, will post them separately, as they now
are not used in added tests;
- dropped arg:untrusted support (Alexei);
- renamed arg:nullable to arg:maybe_null (Alexei);
- and also added task_struct___local flavor tests (Alexei).
Andrii Nakryiko (7):
libbpf: integrate __arg_ctx feature detector into kernel_supports()
libbpf: fix __arg_ctx type enforcement for perf_event programs
bpf: move arg:ctx type enforcement check inside the main logic loop
bpf: add __arg_trusted global func arg tag
bpf: add arg:maybe_null tag to be combined with trusted pointers
libbpf: add __arg_trusted and __arg_maybe_null tag macros
selftests/bpf: add trusted global subprog arg tests
include/linux/bpf_verifier.h | 1 +
kernel/bpf/btf.c | 130 +++++++++++----
kernel/bpf/verifier.c | 24 +++
tools/lib/bpf/bpf_helpers.h | 2 +
tools/lib/bpf/features.c | 58 +++++++
tools/lib/bpf/libbpf.c | 86 +++-------
tools/lib/bpf/libbpf_internal.h | 2 +
.../selftests/bpf/prog_tests/verifier.c | 2 +
.../bpf/progs/verifier_global_ptr_args.c | 156 ++++++++++++++++++
9 files changed, 366 insertions(+), 95 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
--
2.34.1
next reply other threads:[~2024-01-25 20:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 20:55 Andrii Nakryiko [this message]
2024-01-25 20:55 ` [PATCH v2 bpf-next 1/7] libbpf: integrate __arg_ctx feature detector into kernel_supports() Andrii Nakryiko
2024-01-25 20:55 ` [PATCH v2 bpf-next 2/7] libbpf: fix __arg_ctx type enforcement for perf_event programs Andrii Nakryiko
2024-01-26 13:24 ` Eduard Zingerman
2024-01-26 19:06 ` Andrii Nakryiko
2024-01-26 21:32 ` Eduard Zingerman
2024-01-26 22:21 ` Andrii Nakryiko
2024-01-25 20:55 ` [PATCH v2 bpf-next 3/7] bpf: move arg:ctx type enforcement check inside the main logic loop Andrii Nakryiko
2024-01-25 20:55 ` [PATCH v2 bpf-next 4/7] bpf: add __arg_trusted global func arg tag Andrii Nakryiko
2024-01-25 20:55 ` [PATCH v2 bpf-next 5/7] bpf: add arg:maybe_null tag to be combined with trusted pointers Andrii Nakryiko
2024-01-25 20:55 ` [PATCH v2 bpf-next 6/7] libbpf: add __arg_trusted and __arg_maybe_null tag macros Andrii Nakryiko
2024-01-25 20:55 ` [PATCH v2 bpf-next 7/7] selftests/bpf: add trusted global subprog arg tests Andrii Nakryiko
2024-01-29 17:29 ` [PATCH v2 bpf-next 0/7] Trusted PTR_TO_BTF_ID arg support in global subprogs Eduard Zingerman
2024-01-29 20:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240125205510.3642094-1-andrii@kernel.org \
--to=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=martin.lau@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).