selftests/bpf: Test sched_process_wait nullable argument

Add a load-time verifier test that dereferences argument 0 of the
sched_process_wait tp_btf program without checking it. The test expects the
nullable-pointer diagnostic, so it is accepted unexpectedly before the fix
and rejected as expected after it.

Add a successful control that checks the argument for NULL before the
dereference. This ensures the nullable marking preserves legitimate access
to the pid when the tracepoint supplies one.

Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20260903144433.1716731-9-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Kumar Kartikeya Dwivedi 2026-09-03 16:44:26 +02:00 committed by Alexei Starovoitov
parent a453d6e3b8
commit c1992ba73b

View File

@ -58,3 +58,20 @@ int test_tp_btf_signal_deliver_info_no_deref(void *ctx)
asm volatile("r1 = *(u64 *)(r1 +8); r1 = *(u32 *)(r1 +0);" ::: __clobber_all);
return 0;
}
SEC("tp_btf/sched_process_wait")
__failure __msg("R1 invalid mem access 'trusted_ptr_or_null_'")
int test_raw_tp_null_sched_process_wait_arg_1(void *ctx)
{
asm volatile("r1 = *(u64 *)(r1 +0); r1 = *(u32 *)(r1 +0);" ::: __clobber_all);
return 0;
}
SEC("tp_btf/sched_process_wait")
__success
int test_raw_tp_null_sched_process_wait_arg_1_checked(void *ctx)
{
asm volatile("r1 = *(u64 *)(r1 +0); if r1 == 0 goto +1; "
"r1 = *(u32 *)(r1 +0);" ::: __clobber_all);
return 0;
}