diff options
| author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2026-09-21 04:38:25 +0200 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-09-21 17:12:39 +0000 |
| commit | 06046a8a50e85165cfe4cf1b99ac4c0d43781189 (patch) | |
| tree | c042a3bca2c3a882342c0dcdcadd7287ca6be232 /tools/testing/selftests/bpf/test_cpp.cpp | |
| parent | 83aa20cc3585da1742a11da47b5bd4bf0394fbce (diff) | |
| download | linux-next-06046a8a50e85165cfe4cf1b99ac4c0d43781189.tar.gz linux-next-06046a8a50e85165cfe4cf1b99ac4c0d43781189.zip | |
selftests/bpf: Allow privileged preparation for capability tests
The annotation-driven loader drops capabilities before libbpf prepares an
object. Resolving bpf_testmod kfuncs requires CAP_SYS_ADMIN to enumerate and
open module BTF, so tests without that capability fail before reaching the
verifier.
Add an opt-in __prepare_priv annotation. Call bpf_object__prepare() with the
fixture's initial capabilities, then apply __caps_unpriv before loading the
programs. This uses libbpf's explicit prepare/load boundary. In particular,
CAP_SYS_ADMIN must be dropped along with CAP_PERFMON to test uninitialized
stack checks, since CAP_SYS_ADMIN satisfies the verifier's CAP_PERFMON check.
Preparation also creates maps and loads BTF. Keep it opt-in so existing tests
continue checking those operations with reduced capabilities. The existing
pre-execution callback runs after program loading and is too late for this.
Allow tests retaining CAP_BPF to run when the unprivileged-BPF sysctl is set.
Check CPU mitigations separately: disabled or undetectable mitigations must
still skip these tests, because CAP_BPF does not restore speculative
execution checks.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20260921023843.411943-2-memxor@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/test_cpp.cpp')
0 files changed, 0 insertions, 0 deletions
