mirror of
https://github.com/torvalds/linux.git
synced 2026-09-13 06:23:02 +02:00
selftests/bpf: precision of a NULL helper argument
Check that mark_chain_precision() is called for a NULL nullable memory argument and for the zero flags argument of bpf_get_local_storage(). Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20260904-register-is-null-precise-fixes-v1-2-0f5a360ff15d@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
1a3a10b030
commit
593c8eb0fb
|
|
@ -305,4 +305,33 @@ __naked void cpu_cgroup_storage_access_6(void)
|
|||
: __clobber_all);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verification takes two paths: with r2 being scalar zero on path (1)
|
||||
* and with r2 being some other scalar on path (2).
|
||||
* Check that the verifier does not use checkpoints created
|
||||
* on path (1) to prune path (2).
|
||||
*/
|
||||
SEC("cgroup/skb")
|
||||
__failure
|
||||
__flag(BPF_F_TEST_STATE_FREQ)
|
||||
__msg("get_local_storage() doesn't support non-zero flags")
|
||||
__naked void non_zero_flags_on_a_pruned_path(void)
|
||||
{
|
||||
asm volatile (" \
|
||||
call %[bpf_get_prandom_u32]; \
|
||||
/* r2 is 0 on the path explored first, 1 on the other */\
|
||||
r2 = 1; \
|
||||
if r0 == 0 goto 1f; \
|
||||
r2 = 0; \
|
||||
1: r1 = %[cgroup_storage] ll; \
|
||||
call %[bpf_get_local_storage]; \
|
||||
r0 = 0; \
|
||||
exit; \
|
||||
" :
|
||||
: __imm(bpf_get_prandom_u32),
|
||||
__imm(bpf_get_local_storage),
|
||||
__imm_addr(cgroup_storage)
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
|
|
|||
|
|
@ -642,4 +642,38 @@ __naked int bpf_atomic_cmpxchg_32bit_precision(void)
|
|||
: __clobber_all);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verification takes two paths: with r1 being scalar zero on path (1)
|
||||
* and with r1 being some other scalar on path (2).
|
||||
* Check that the verifier does not use checkpoints created
|
||||
* on path (1) to prune path (2).
|
||||
*/
|
||||
SEC("?tc")
|
||||
__flag(BPF_F_TEST_STATE_FREQ)
|
||||
__failure __msg("R1 type=scalar expected=fp")
|
||||
__naked int null_mem_arg_zero_size(void)
|
||||
{
|
||||
asm volatile (
|
||||
"call %[bpf_get_prandom_u32];"
|
||||
"r1 = 42;"
|
||||
"if r0 > 42 goto 1f;"
|
||||
"r1 = 0;"
|
||||
"1:"
|
||||
"r2 = 0;"
|
||||
"r3 = 0;"
|
||||
"r4 = 0;"
|
||||
"r5 = 0;"
|
||||
/*
|
||||
* ARG_PTR_TO_MEM | PTR_MAYBE_NULL parameter can be NULL,
|
||||
* but can't be some other scalar value.
|
||||
*/
|
||||
"call %[bpf_csum_diff];"
|
||||
"r0 = 0;"
|
||||
"exit;"
|
||||
:
|
||||
: __imm(bpf_get_prandom_u32),
|
||||
__imm(bpf_csum_diff)
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user