diff options
author | Eduard Zingerman <eddyz87@gmail.com> | 2025-07-02 00:36:20 -0700 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2025-07-02 10:43:30 -0700 |
commit | a90f5f7370c283863d3872f231debc9b2227b27f (patch) | |
tree | 8e276292043e96540c5a97ee450ec169b2aeaa4b | |
parent | c3b9faac9bd690263e03b78eb78c75cae5ff7509 (diff) |
selftests/bpf: null checks for rdonly_untrusted_mem should be preserved
Test case checking that verifier does not assume rdonly_untrusted_mem
values as not null.
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20250702073620.897517-2-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
-rw-r--r-- | tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c b/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c index b0486af36f55..8185130ede95 100644 --- a/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c +++ b/tools/testing/selftests/bpf/progs/mem_rdonly_untrusted.c @@ -174,4 +174,25 @@ int misaligned_access(void *ctx) return combine(bpf_rdonly_cast(&global, 0) + 1); } +__weak int return_one(void) +{ + return 1; +} + +SEC("socket") +__success +__retval(1) +int null_check(void *ctx) +{ + int *p; + + p = bpf_rdonly_cast(0, 0); + if (p == 0) + /* make this a function call to avoid compiler + * moving r0 assignment before check. + */ + return return_one(); + return 0; +} + char _license[] SEC("license") = "GPL"; |