Commit 973cb138 authored by Daniel Xu's avatar Daniel Xu Committed by Alexei Starovoitov
Browse files

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: default avatarEduard Zingerman <eddyz87@gmail.com>
Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/c0590b62eb9303f389b2f52c0c7e9cf22a358a30.1738689872.git.dxu@dxuuu.xyz


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 884c3a18
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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";