Skip to content

Commit 973cb13

Browse files
danobiAlexei Starovoitov
authored andcommitted
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>
1 parent 884c3a1 commit 973cb13

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tools/testing/selftests/bpf/progs/verifier_array_access.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,4 +713,19 @@ unsigned int non_stack_key_lookup(void)
713713
return val->index;
714714
}
715715

716+
SEC("socket")
717+
__description("doesn't reject UINT64_MAX as s64 for irrelevant maps")
718+
__success __retval(42)
719+
unsigned int doesnt_reject_irrelevant_maps(void)
720+
{
721+
__u64 key = 0xFFFFFFFFFFFFFFFF;
722+
struct test_val *val;
723+
724+
val = bpf_map_lookup_elem(&map_hash_48b, &key);
725+
if (val)
726+
return val->index;
727+
728+
return 42;
729+
}
730+
716731
char _license[] SEC("license") = "GPL";

0 commit comments

Comments
 (0)