mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
selftests/bpf: Cover pseudo-BTF ksym log masking
Add verifier_unpriv coverage for a raw socket-filter load of the bpf_prog_active typed ksym. The test verifies that the unprivileged load remains accepted and that the verbose verifier log prints the ldimm64 immediate as 0x0 instead of exposing a nonzero kernel address. Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn> Link: https://lore.kernel.org/r/20260623-f01-13-pseudo-btf-id-cap-bpf-v2-2-a190ebb8f3e2@mails.tsinghua.edu.cn Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Eduard Zingerman <eddyz87@gmail.com>
This commit is contained in:
parent
72a85e9464
commit
8a870967ca
|
|
@ -6,6 +6,8 @@
|
|||
#include "../../../include/linux/filter.h"
|
||||
#include "bpf_misc.h"
|
||||
|
||||
extern const int bpf_prog_active __ksym;
|
||||
|
||||
#define BPF_SK_LOOKUP(func) \
|
||||
/* struct bpf_sock_tuple tuple = {} */ \
|
||||
"r2 = 0;" \
|
||||
|
|
@ -77,6 +79,23 @@ __naked void dummy_prog_loop1_socket(void)
|
|||
: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("socket")
|
||||
__description("unpriv: pseudo btf id log masks address")
|
||||
__success_unpriv
|
||||
__msg_unpriv("0: (18) r1 = 0x0")
|
||||
__not_msg_unpriv("0: (18) r1 = 0x{{[1-9a-f][0-9a-f]*}}")
|
||||
__retval_unpriv(0)
|
||||
__log_level(2)
|
||||
__naked void pseudo_btf_id_log_masks_address(void)
|
||||
{
|
||||
asm volatile ("r1 = %[bpf_prog_active] ll;"
|
||||
"r0 = 0;"
|
||||
"exit;"
|
||||
:
|
||||
: __imm_addr(bpf_prog_active)
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
SEC("socket")
|
||||
__description("unpriv: return pointer")
|
||||
__success __failure_unpriv __msg_unpriv("R0 leaks addr")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user