1 // SPDX-License-Identifier: GPL-2.0
2 /* Converted from tools/testing/selftests/bpf/verifier/prevent_map_lookup.c */
5 #include <bpf/bpf_helpers.h>
9 __uint(type, BPF_MAP_TYPE_STACK_TRACE);
10 __uint(max_entries, 1);
13 } map_stacktrace SEC(".maps");
16 __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
17 __uint(max_entries, 8);
18 __uint(key_size, sizeof(int));
19 __array(values, void (void));
20 } map_prog2_socket SEC(".maps");
23 __description("prevent map lookup in stack trace")
24 __failure __msg("cannot pass map_type 7 into func bpf_map_lookup_elem")
25 __naked void map_lookup_in_stack_trace(void)
29 *(u64*)(r10 - 8) = r1; \
32 r1 = %[map_stacktrace] ll; \
33 call %[bpf_map_lookup_elem]; \
36 : __imm(bpf_map_lookup_elem),
37 __imm_addr(map_stacktrace)
42 __description("prevent map lookup in prog array")
43 __failure __msg("cannot pass map_type 3 into func bpf_map_lookup_elem")
45 __naked void map_lookup_in_prog_array(void)
49 *(u64*)(r10 - 8) = r1; \
52 r1 = %[map_prog2_socket] ll; \
53 call %[bpf_map_lookup_elem]; \
56 : __imm(bpf_map_lookup_elem),
57 __imm_addr(map_prog2_socket)
61 char _license[] SEC("license") = "GPL";