mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
selftests/bpf: Test pseudo-function policy diagnostics
Load a socket-filter program that passes a callback to bpf_loop() without making a BPF-to-BPF call. Verify that the privileged load succeeds and the unprivileged Policy report identifies the BPF function reference at its ldimm64 instruction. Also reject the inaccurate BPF-to-BPF call wording in the portion of the log covered by the structured report. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/bpf/d02e6a6d3b2dc43a207b8ba836ce62497b250dede9252e7409c5212201c794b7@mail.kernel.org Link: https://lore.kernel.org/bpf/20260816015746.2632990-15-memxor@gmail.com
This commit is contained in:
parent
fc009f4658
commit
6ab6a94c4f
|
|
@ -96,6 +96,24 @@ __naked void pseudo_btf_id_log_masks_address(void)
|
|||
: __clobber_all);
|
||||
}
|
||||
|
||||
static int pseudo_func_callback(__u32 index, void *ctx)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEC("socket")
|
||||
__description("unpriv: pseudo function policy diagnostic")
|
||||
__success __failure_unpriv
|
||||
__msg_unpriv("loading/calling other bpf or kernel functions")
|
||||
__not_msg_unpriv("BPF-to-BPF function call")
|
||||
__msg_unpriv("policy check failed for BPF function reference")
|
||||
__msg_unpriv("avoid BPF function references in unprivileged")
|
||||
int unpriv_pseudo_func_policy(void *ctx)
|
||||
{
|
||||
bpf_loop(1, pseudo_func_callback, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEC("socket")
|
||||
__description("unpriv: return pointer")
|
||||
__success __failure_unpriv __msg_unpriv("R0 leaks addr")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user