From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org
Cc: daniel@iogearbox.net, martin.lau@linux.dev, kernel-team@fb.com,
yonghong.song@linux.dev, eddyz87@gmail.com, memxor@gmail.com
Subject: [PATCH bpf 02/10] selftests/bpf: precision of a NULL helper argument
Date: Fri, 4 Sep 2026 17:05:53 -0700 [thread overview]
Message-ID: <20260904-register-is-null-precise-fixes-v1-2-0f5a360ff15d@gmail.com> (raw)
In-Reply-To: <20260904-register-is-null-precise-fixes-v1-0-0f5a360ff15d@gmail.com>
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>
---
.../selftests/bpf/progs/verifier_cgroup_storage.c | 29 ++++++++++++++++++
.../selftests/bpf/progs/verifier_precision.c | 34 ++++++++++++++++++++++
2 files changed, 63 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/verifier_cgroup_storage.c b/tools/testing/selftests/bpf/progs/verifier_cgroup_storage.c
index 9a13f5c11ac7..884080a5bffc 100644
--- a/tools/testing/selftests/bpf/progs/verifier_cgroup_storage.c
+++ b/tools/testing/selftests/bpf/progs/verifier_cgroup_storage.c
@@ -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";
diff --git a/tools/testing/selftests/bpf/progs/verifier_precision.c b/tools/testing/selftests/bpf/progs/verifier_precision.c
index 6f325876efdd..3e290b07f672 100644
--- a/tools/testing/selftests/bpf/progs/verifier_precision.c
+++ b/tools/testing/selftests/bpf/progs/verifier_precision.c
@@ -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";
--
2.55.0
next prev parent reply other threads:[~2026-09-05 0:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-05 0:05 [PATCH bpf 00/10] bpf: add missing precision propagation after bpf_register_is_null calls Eduard Zingerman
2026-09-05 0:05 ` [PATCH bpf 01/10] bpf: mark a NULL call argument precise Eduard Zingerman
2026-09-05 0:21 ` sashiko-bot
2026-09-05 0:05 ` Eduard Zingerman [this message]
2026-09-05 0:05 ` [PATCH bpf 03/10] bpf: mark a NULL memory argument of a call precise Eduard Zingerman
2026-09-05 0:23 ` sashiko-bot
2026-09-05 0:51 ` bot+bpf-ci
2026-09-05 0:05 ` [PATCH bpf 04/10] selftests/bpf: precision of a NULL global subprogram memory argument Eduard Zingerman
2026-09-05 0:51 ` bot+bpf-ci
2026-09-05 0:05 ` [PATCH bpf 05/10] bpf: mark a NULL kfunc argument precise Eduard Zingerman
2026-09-05 0:51 ` bot+bpf-ci
2026-09-05 0:05 ` [PATCH bpf 06/10] selftests/bpf: precision of a NULL kfunc argument Eduard Zingerman
2026-09-05 0:05 ` [PATCH bpf 07/10] bpf: mark a NULL BTF_ID argument of a global subprogram precise Eduard Zingerman
2026-09-05 0:19 ` sashiko-bot
2026-09-05 0:05 ` [PATCH bpf 08/10] selftests/bpf: precision of a NULL global subprogram BTF_ID argument Eduard Zingerman
2026-09-05 0:06 ` [PATCH bpf 09/10] bpf: propagate mark_chain_precision() errors out of loop_flag_is_zero() Eduard Zingerman
2026-09-05 0:06 ` [PATCH bpf 10/10] bpf: use mark_arg_precision() in check_mem_size_reg() Eduard Zingerman
2026-09-05 0:51 ` bot+bpf-ci
2026-09-05 1:20 ` [PATCH bpf 00/10] bpf: add missing precision propagation after bpf_register_is_null calls patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260904-register-is-null-precise-fixes-v1-2-0f5a360ff15d@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.