Skip to content

Commit

Permalink
bpf: selftests: Test constant key extraction on irrelevant maps
Browse files Browse the repository at this point in the history
Test that very high constant map keys are not interpreted as an error
value by the verifier. This would previously fail.

Signed-off-by: Daniel Xu <[email protected]>
  • Loading branch information
danobi authored and Kernel Patches Daemon committed Feb 3, 2025
1 parent b8fc22e commit e240e45
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tools/testing/selftests/bpf/progs/verifier_array_access.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit e240e45

Please sign in to comment.