mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-11 01:10:54 -04:00
selftests/bpf: precision of a NULL global subprogram memory argument
Check that mark_chain_precision() is called for a NULL pointer passed as a nullable pointer argument of a global subprogram. (Pointer arguments of the global subprograms are nullable by default). Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20260904-register-is-null-precise-fixes-v1-4-0f5a360ff15d@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
f1e418129f
commit
100f4cc0d5
@@ -676,4 +676,36 @@ __naked int null_mem_arg_zero_size(void)
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
__weak int subprog_mem_arg(int *p)
|
||||
{
|
||||
if (p)
|
||||
return *p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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("?raw_tp")
|
||||
__flag(BPF_F_TEST_STATE_FREQ)
|
||||
__failure __msg("R1 type=scalar expected=fp")
|
||||
__naked int null_mem_arg_global_subprog(void)
|
||||
{
|
||||
asm volatile (
|
||||
"call %[bpf_get_prandom_u32];"
|
||||
"r1 = 42;"
|
||||
"if r0 > 42 goto 1f;"
|
||||
"r1 = 0;"
|
||||
"1:"
|
||||
"call subprog_mem_arg;"
|
||||
"r0 = 0;"
|
||||
"exit;"
|
||||
:
|
||||
: __imm(bpf_get_prandom_u32)
|
||||
: __clobber_all);
|
||||
}
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
||||
Reference in New Issue
Block a user