diff options
author | Daniel Xu <dxu@dxuuu.xyz> | 2025-02-04 10:25:17 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2025-02-07 15:45:44 -0800 |
commit | 973cb1382ead401c476c82f20525e593ae84788f (patch) | |
tree | ef47505d828d1f0e7190dd30571b39b5a650d3d9 | |
parent | 884c3a18dadfda326dffa364477cc027728219de (diff) |
bpf: selftests: Test constant key extraction on irrelevant maps
Test that very high constant map keys are not interpreted as an error
value by the verifier. This would previously fail.
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/c0590b62eb9303f389b2f52c0c7e9cf22a358a30.1738689872.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | tools/testing/selftests/bpf/progs/verifier_array_access.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/verifier_array_access.c b/tools/testing/selftests/bpf/progs/verifier_array_access.c index 29eb9568633f..0a187ff725cc 100644 --- a/tools/testing/selftests/bpf/progs/verifier_array_access.c +++ b/tools/testing/selftests/bpf/progs/verifier_array_access.c @@ -713,4 +713,19 @@ unsigned int non_stack_key_lookup(void) return val->index; } +SEC("socket") +__description("doesn't reject UINT64_MAX as s64 for irrelevant maps") +__success __retval(42) +unsigned int doesnt_reject_irrelevant_maps(void) +{ + __u64 key = 0xFFFFFFFFFFFFFFFF; + struct test_val *val; + + val = bpf_map_lookup_elem(&map_hash_48b, &key); + if (val) + return val->index; + + return 42; +} + char _license[] SEC("license") = "GPL"; |