]> git.hungrycats.org Git - linux/commitdiff
selftests/bpf: precision of a NULL global subprogram BTF_ID argument
authorEduard Zingerman <eddyz87@gmail.com>
Sat, 5 Sep 2026 00:05:59 +0000 (17:05 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 5 Sep 2026 01:17:30 +0000 (18:17 -0700)
Check that mark_chain_precision() is called for a NULL pointer passed
as an __arg_trusted __arg_nullable argument of a global subprogram.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20260904-register-is-null-precise-fixes-v1-8-0f5a360ff15d@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c

index 0bdeb7bc4687a9abde1cfa6d63ea769259404dbc..a3d2af8dc8396be0c5c493c403a82f2a0e1fa043 100644 (file)
@@ -56,6 +56,30 @@ int trusted_task_arg_nullable(void *ctx)
        return res;
 }
 
+/*
+ * Check that the verifier does not use checkpoints created
+ * on path with r1 == 0 to prune path with r1 != 0.
+ */
+SEC("?tp_btf/task_newtask")
+__failure
+__flag(BPF_F_TEST_STATE_FREQ)
+__msg("R1 type=scalar expected=ptr_, trusted_ptr_, rcu_ptr_")
+__naked int null_btf_id_arg_global_subprog(void)
+{
+       asm volatile (
+               "call %[bpf_get_prandom_u32];"
+               "r1 = 42;"
+               "if r0 > 42 goto 1f;"
+               "r1 = 0;"
+       "1:"
+               "call subprog_trusted_task_nullable;"
+               "r0 = 0;"
+               "exit;"
+               :
+               : __imm(bpf_get_prandom_u32)
+               : __clobber_all);
+}
+
 __weak int subprog_trusted_task_nonnull(struct task_struct *task __arg_trusted)
 {
        return task->pid + task->tgid;