selftests/bpf: verifier/helper_value_access.c converted to inline assembly
authorEduard Zingerman <eddyz87@gmail.com>
Sat, 25 Mar 2023 02:55:04 +0000 (04:55 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 26 Mar 2023 00:02:04 +0000 (17:02 -0700)
Test verifier/helper_value_access.c automatically converted to use inline assembly.

Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20230325025524.144043-24-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/verifier.c
tools/testing/selftests/bpf/progs/verifier_helper_value_access.c [new file with mode: 0644]
tools/testing/selftests/bpf/verifier/helper_value_access.c [deleted file]

index 02983d1de218abd13118ac7d756c501ca97296e6..2c3745a1fdcbb29733f01d3bc357c4ad91bf0d1d 100644 (file)
@@ -20,6 +20,7 @@
 #include "verifier_helper_access_var_len.skel.h"
 #include "verifier_helper_packet_access.skel.h"
 #include "verifier_helper_restricted.skel.h"
+#include "verifier_helper_value_access.skel.h"
 
 __maybe_unused
 static void run_tests_aux(const char *skel_name, skel_elf_bytes_fn elf_bytes_factory)
@@ -62,3 +63,4 @@ void test_verifier_div_overflow(void)         { RUN(verifier_div_overflow); }
 void test_verifier_helper_access_var_len(void) { RUN(verifier_helper_access_var_len); }
 void test_verifier_helper_packet_access(void) { RUN(verifier_helper_packet_access); }
 void test_verifier_helper_restricted(void)    { RUN(verifier_helper_restricted); }
+void test_verifier_helper_value_access(void)  { RUN(verifier_helper_value_access); }
diff --git a/tools/testing/selftests/bpf/progs/verifier_helper_value_access.c b/tools/testing/selftests/bpf/progs/verifier_helper_value_access.c
new file mode 100644 (file)
index 0000000..692216c
--- /dev/null
@@ -0,0 +1,1245 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Converted from tools/testing/selftests/bpf/verifier/helper_value_access.c */
+
+#include <linux/bpf.h>
+#include <bpf/bpf_helpers.h>
+#include "bpf_misc.h"
+
+struct other_val {
+       long long foo;
+       long long bar;
+};
+
+struct {
+       __uint(type, BPF_MAP_TYPE_HASH);
+       __uint(max_entries, 1);
+       __type(key, long long);
+       __type(value, struct other_val);
+} map_hash_16b SEC(".maps");
+
+#define MAX_ENTRIES 11
+
+struct test_val {
+       unsigned int index;
+       int foo[MAX_ENTRIES];
+};
+
+struct {
+       __uint(type, BPF_MAP_TYPE_HASH);
+       __uint(max_entries, 1);
+       __type(key, long long);
+       __type(value, struct test_val);
+} map_hash_48b SEC(".maps");
+
+struct {
+       __uint(type, BPF_MAP_TYPE_HASH);
+       __uint(max_entries, 1);
+       __type(key, long long);
+       __type(value, long long);
+} map_hash_8b SEC(".maps");
+
+SEC("tracepoint")
+__description("helper access to map: full range")
+__success
+__naked void access_to_map_full_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r2 = %[sizeof_test_val];                        \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(sizeof_test_val, sizeof(struct test_val))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: partial range")
+__success
+__naked void access_to_map_partial_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r2 = 8;                                         \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: empty range")
+__failure __msg("invalid access to map value, value_size=48 off=0 size=0")
+__naked void access_to_map_empty_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r2 = 0;                                         \
+       call %[bpf_trace_printk];                       \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_trace_printk),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: out-of-bound range")
+__failure __msg("invalid access to map value, value_size=48 off=0 size=56")
+__naked void map_out_of_bound_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r2 = %[__imm_0];                                \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(__imm_0, sizeof(struct test_val) + 8)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: negative range")
+__failure __msg("R2 min value is negative")
+__naked void access_to_map_negative_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r2 = -8;                                        \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const imm): full range")
+__success
+__naked void via_const_imm_full_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r1 += %[test_val_foo];                          \
+       r2 = %[__imm_0];                                \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(__imm_0, sizeof(struct test_val) - offsetof(struct test_val, foo)),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const imm): partial range")
+__success
+__naked void via_const_imm_partial_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r1 += %[test_val_foo];                          \
+       r2 = 8;                                         \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const imm): empty range")
+__failure __msg("invalid access to map value, value_size=48 off=4 size=0")
+__naked void via_const_imm_empty_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r1 += %[test_val_foo];                          \
+       r2 = 0;                                         \
+       call %[bpf_trace_printk];                       \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_trace_printk),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const imm): out-of-bound range")
+__failure __msg("invalid access to map value, value_size=48 off=4 size=52")
+__naked void imm_out_of_bound_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r1 += %[test_val_foo];                          \
+       r2 = %[__imm_0];                                \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(__imm_0, sizeof(struct test_val) - offsetof(struct test_val, foo) + 8),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const imm): negative range (> adjustment)")
+__failure __msg("R2 min value is negative")
+__naked void const_imm_negative_range_adjustment_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r1 += %[test_val_foo];                          \
+       r2 = -8;                                        \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const imm): negative range (< adjustment)")
+__failure __msg("R2 min value is negative")
+__naked void const_imm_negative_range_adjustment_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r1 += %[test_val_foo];                          \
+       r2 = -1;                                        \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const reg): full range")
+__success
+__naked void via_const_reg_full_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = %[test_val_foo];                           \
+       r1 += r3;                                       \
+       r2 = %[__imm_0];                                \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(__imm_0, sizeof(struct test_val) - offsetof(struct test_val, foo)),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const reg): partial range")
+__success
+__naked void via_const_reg_partial_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = %[test_val_foo];                           \
+       r1 += r3;                                       \
+       r2 = 8;                                         \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const reg): empty range")
+__failure __msg("R1 min value is outside of the allowed memory range")
+__naked void via_const_reg_empty_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = 0;                                         \
+       r1 += r3;                                       \
+       r2 = 0;                                         \
+       call %[bpf_trace_printk];                       \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_trace_printk),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const reg): out-of-bound range")
+__failure __msg("invalid access to map value, value_size=48 off=4 size=52")
+__naked void reg_out_of_bound_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = %[test_val_foo];                           \
+       r1 += r3;                                       \
+       r2 = %[__imm_0];                                \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(__imm_0, sizeof(struct test_val) - offsetof(struct test_val, foo) + 8),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const reg): negative range (> adjustment)")
+__failure __msg("R2 min value is negative")
+__naked void const_reg_negative_range_adjustment_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = %[test_val_foo];                           \
+       r1 += r3;                                       \
+       r2 = -8;                                        \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via const reg): negative range (< adjustment)")
+__failure __msg("R2 min value is negative")
+__naked void const_reg_negative_range_adjustment_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = %[test_val_foo];                           \
+       r1 += r3;                                       \
+       r2 = -1;                                        \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via variable): full range")
+__success
+__naked void map_via_variable_full_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 > %[test_val_foo] goto l0_%=;             \
+       r1 += r3;                                       \
+       r2 = %[__imm_0];                                \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(__imm_0, sizeof(struct test_val) - offsetof(struct test_val, foo)),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via variable): partial range")
+__success
+__naked void map_via_variable_partial_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 > %[test_val_foo] goto l0_%=;             \
+       r1 += r3;                                       \
+       r2 = 8;                                         \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via variable): empty range")
+__failure __msg("R1 min value is outside of the allowed memory range")
+__naked void map_via_variable_empty_range(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 > %[test_val_foo] goto l0_%=;             \
+       r1 += r3;                                       \
+       r2 = 0;                                         \
+       call %[bpf_trace_printk];                       \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_trace_printk),
+         __imm_addr(map_hash_48b),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via variable): no max check")
+__failure __msg("R1 unbounded memory access")
+__naked void via_variable_no_max_check_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       r1 += r3;                                       \
+       r2 = 1;                                         \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to adjusted map (via variable): wrong max check")
+__failure __msg("invalid access to map value, value_size=48 off=4 size=45")
+__naked void via_variable_wrong_max_check_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 > %[test_val_foo] goto l0_%=;             \
+       r1 += r3;                                       \
+       r2 = %[__imm_0];                                \
+       r3 = 0;                                         \
+       call %[bpf_probe_read_kernel];                  \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_probe_read_kernel),
+         __imm_addr(map_hash_48b),
+         __imm_const(__imm_0, sizeof(struct test_val) - offsetof(struct test_val, foo) + 1),
+         __imm_const(test_val_foo, offsetof(struct test_val, foo))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using <, good access")
+__success
+__naked void bounds_check_using_good_access_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 < 32 goto l1_%=;                          \
+       r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using <, bad access")
+__failure __msg("R1 unbounded memory access")
+__naked void bounds_check_using_bad_access_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 < 32 goto l1_%=;                          \
+       r1 += r3;                                       \
+l0_%=: r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+l1_%=: r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using <=, good access")
+__success
+__naked void bounds_check_using_good_access_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 <= 32 goto l1_%=;                         \
+       r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using <=, bad access")
+__failure __msg("R1 unbounded memory access")
+__naked void bounds_check_using_bad_access_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 <= 32 goto l1_%=;                         \
+       r1 += r3;                                       \
+l0_%=: r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+l1_%=: r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using s<, good access")
+__success
+__naked void check_using_s_good_access_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 s< 32 goto l1_%=;                         \
+l2_%=: r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: if r3 s< 0 goto l2_%=;                          \
+       r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using s<, good access 2")
+__success
+__naked void using_s_good_access_2_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 s< 32 goto l1_%=;                         \
+l2_%=: r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: if r3 s< -3 goto l2_%=;                         \
+       r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using s<, bad access")
+__failure __msg("R1 min value is negative")
+__naked void check_using_s_bad_access_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u64*)(r0 + 0);                           \
+       if r3 s< 32 goto l1_%=;                         \
+l2_%=: r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: if r3 s< -3 goto l2_%=;                         \
+       r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using s<=, good access")
+__success
+__naked void check_using_s_good_access_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 s<= 32 goto l1_%=;                        \
+l2_%=: r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: if r3 s<= 0 goto l2_%=;                         \
+       r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using s<=, good access 2")
+__success
+__naked void using_s_good_access_2_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 s<= 32 goto l1_%=;                        \
+l2_%=: r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: if r3 s<= -3 goto l2_%=;                        \
+       r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("helper access to map: bounds check using s<=, bad access")
+__failure __msg("R1 min value is negative")
+__naked void check_using_s_bad_access_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_48b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r1 = r0;                                        \
+       r3 = *(u64*)(r0 + 0);                           \
+       if r3 s<= 32 goto l1_%=;                        \
+l2_%=: r0 = 0;                                         \
+l0_%=: exit;                                           \
+l1_%=: if r3 s<= -3 goto l2_%=;                        \
+       r1 += r3;                                       \
+       r0 = 0;                                         \
+       *(u8*)(r1 + 0) = r0;                            \
+       r0 = 0;                                         \
+       exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_48b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map lookup helper access to map")
+__success
+__naked void lookup_helper_access_to_map(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map update helper access to map")
+__success
+__naked void update_helper_access_to_map(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r4 = 0;                                         \
+       r3 = r0;                                        \
+       r2 = r0;                                        \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_update_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_map_update_elem),
+         __imm_addr(map_hash_16b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map update helper access to map: wrong size")
+__failure __msg("invalid access to map value, value_size=8 off=0 size=16")
+__naked void access_to_map_wrong_size(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_8b] ll;                         \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r4 = 0;                                         \
+       r3 = r0;                                        \
+       r2 = r0;                                        \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_update_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm(bpf_map_update_elem),
+         __imm_addr(map_hash_16b),
+         __imm_addr(map_hash_8b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via const imm)")
+__success
+__naked void adjusted_map_via_const_imm(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r2 += %[other_val_bar];                         \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b),
+         __imm_const(other_val_bar, offsetof(struct other_val, bar))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via const imm): out-of-bound 1")
+__failure __msg("invalid access to map value, value_size=16 off=12 size=8")
+__naked void imm_out_of_bound_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r2 += %[__imm_0];                               \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b),
+         __imm_const(__imm_0, sizeof(struct other_val) - 4)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via const imm): out-of-bound 2")
+__failure __msg("invalid access to map value, value_size=16 off=-4 size=8")
+__naked void imm_out_of_bound_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r2 += -4;                                       \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via const reg)")
+__success
+__naked void adjusted_map_via_const_reg(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r3 = %[other_val_bar];                          \
+       r2 += r3;                                       \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b),
+         __imm_const(other_val_bar, offsetof(struct other_val, bar))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via const reg): out-of-bound 1")
+__failure __msg("invalid access to map value, value_size=16 off=12 size=8")
+__naked void reg_out_of_bound_1(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r3 = %[__imm_0];                                \
+       r2 += r3;                                       \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b),
+         __imm_const(__imm_0, sizeof(struct other_val) - 4)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via const reg): out-of-bound 2")
+__failure __msg("invalid access to map value, value_size=16 off=-4 size=8")
+__naked void reg_out_of_bound_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r3 = -4;                                        \
+       r2 += r3;                                       \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via variable)")
+__success
+__naked void to_adjusted_map_via_variable(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 > %[other_val_bar] goto l0_%=;            \
+       r2 += r3;                                       \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b),
+         __imm_const(other_val_bar, offsetof(struct other_val, bar))
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via variable): no max check")
+__failure
+__msg("R2 unbounded memory access, make sure to bounds check any such access")
+__naked void via_variable_no_max_check_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       r2 += r3;                                       \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b)
+       : __clobber_all);
+}
+
+SEC("tracepoint")
+__description("map helper access to adjusted map (via variable): wrong max check")
+__failure __msg("invalid access to map value, value_size=16 off=9 size=8")
+__naked void via_variable_wrong_max_check_2(void)
+{
+       asm volatile ("                                 \
+       r2 = r10;                                       \
+       r2 += -8;                                       \
+       r1 = 0;                                         \
+       *(u64*)(r2 + 0) = r1;                           \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+       if r0 == 0 goto l0_%=;                          \
+       r2 = r0;                                        \
+       r3 = *(u32*)(r0 + 0);                           \
+       if r3 > %[__imm_0] goto l0_%=;                  \
+       r2 += r3;                                       \
+       r1 = %[map_hash_16b] ll;                        \
+       call %[bpf_map_lookup_elem];                    \
+l0_%=: exit;                                           \
+"      :
+       : __imm(bpf_map_lookup_elem),
+         __imm_addr(map_hash_16b),
+         __imm_const(__imm_0, offsetof(struct other_val, bar) + 1)
+       : __clobber_all);
+}
+
+char _license[] SEC("license") = "GPL";
diff --git a/tools/testing/selftests/bpf/verifier/helper_value_access.c b/tools/testing/selftests/bpf/verifier/helper_value_access.c
deleted file mode 100644 (file)
index 1c7882d..0000000
+++ /dev/null
@@ -1,953 +0,0 @@
-{
-       "helper access to map: full range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_2, sizeof(struct test_val)),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: partial range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_2, 8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: empty range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_2, 0),
-       BPF_EMIT_CALL(BPF_FUNC_trace_printk),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "invalid access to map value, value_size=48 off=0 size=0",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: out-of-bound range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_2, sizeof(struct test_val) + 8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "invalid access to map value, value_size=48 off=0 size=56",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: negative range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_2, -8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R2 min value is negative",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const imm): full range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_2,
-                     sizeof(struct test_val) - offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const imm): partial range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_2, 8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const imm): empty range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_2, 0),
-       BPF_EMIT_CALL(BPF_FUNC_trace_printk),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "invalid access to map value, value_size=48 off=4 size=0",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const imm): out-of-bound range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_2,
-                     sizeof(struct test_val) - offsetof(struct test_val, foo) + 8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "invalid access to map value, value_size=48 off=4 size=52",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const imm): negative range (> adjustment)",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_2, -8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R2 min value is negative",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const imm): negative range (< adjustment)",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_2, -1),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R2 min value is negative",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const reg): full range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, offsetof(struct test_val, foo)),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2,
-                     sizeof(struct test_val) - offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const reg): partial range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, offsetof(struct test_val, foo)),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2, 8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const reg): empty range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2, 0),
-       BPF_EMIT_CALL(BPF_FUNC_trace_printk),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R1 min value is outside of the allowed memory range",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const reg): out-of-bound range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, offsetof(struct test_val, foo)),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2,
-                     sizeof(struct test_val) -
-                     offsetof(struct test_val, foo) + 8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "invalid access to map value, value_size=48 off=4 size=52",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const reg): negative range (> adjustment)",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, offsetof(struct test_val, foo)),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2, -8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R2 min value is negative",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via const reg): negative range (< adjustment)",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, offsetof(struct test_val, foo)),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2, -1),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R2 min value is negative",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via variable): full range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JGT, BPF_REG_3, offsetof(struct test_val, foo), 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2,
-                     sizeof(struct test_val) - offsetof(struct test_val, foo)),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via variable): partial range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JGT, BPF_REG_3, offsetof(struct test_val, foo), 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2, 8),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via variable): empty range",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JGT, BPF_REG_3, offsetof(struct test_val, foo), 3),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2, 0),
-       BPF_EMIT_CALL(BPF_FUNC_trace_printk),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R1 min value is outside of the allowed memory range",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via variable): no max check",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2, 1),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "R1 unbounded memory access",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to adjusted map (via variable): wrong max check",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JGT, BPF_REG_3, offsetof(struct test_val, foo), 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_MOV64_IMM(BPF_REG_2,
-                     sizeof(struct test_val) -
-                     offsetof(struct test_val, foo) + 1),
-       BPF_MOV64_IMM(BPF_REG_3, 0),
-       BPF_EMIT_CALL(BPF_FUNC_probe_read_kernel),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .errstr = "invalid access to map value, value_size=48 off=4 size=45",
-       .result = REJECT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using <, good access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JLT, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using <, bad access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JLT, BPF_REG_3, 32, 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = REJECT,
-       .errstr = "R1 unbounded memory access",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using <=, good access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JLE, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using <=, bad access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JLE, BPF_REG_3, 32, 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = REJECT,
-       .errstr = "R1 unbounded memory access",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using s<, good access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JSLT, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_JMP_IMM(BPF_JSLT, BPF_REG_3, 0, -3),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using s<, good access 2",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JSLT, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_JMP_IMM(BPF_JSLT, BPF_REG_3, -3, -3),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using s<, bad access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_DW, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JSLT, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_JMP_IMM(BPF_JSLT, BPF_REG_3, -3, -3),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = REJECT,
-       .errstr = "R1 min value is negative",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using s<=, good access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JSLE, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_JMP_IMM(BPF_JSLE, BPF_REG_3, 0, -3),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using s<=, good access 2",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JSLE, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_JMP_IMM(BPF_JSLE, BPF_REG_3, -3, -3),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "helper access to map: bounds check using s<=, bad access",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
-       BPF_LDX_MEM(BPF_DW, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JSLE, BPF_REG_3, 32, 2),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       BPF_JMP_IMM(BPF_JSLE, BPF_REG_3, -3, -3),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
-       BPF_ST_MEM(BPF_B, BPF_REG_1, 0, 0),
-       BPF_MOV64_IMM(BPF_REG_0, 0),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_48b = { 3 },
-       .result = REJECT,
-       .errstr = "R1 min value is negative",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map lookup helper access to map",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 8 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map update helper access to map",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_IMM(BPF_REG_4, 0),
-       BPF_MOV64_REG(BPF_REG_3, BPF_REG_0),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 10 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map update helper access to map: wrong size",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_IMM(BPF_REG_4, 0),
-       BPF_MOV64_REG(BPF_REG_3, BPF_REG_0),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_update_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_8b = { 3 },
-       .fixup_map_hash_16b = { 10 },
-       .result = REJECT,
-       .errstr = "invalid access to map value, value_size=8 off=0 size=16",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via const imm)",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, offsetof(struct other_val, bar)),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 9 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via const imm): out-of-bound 1",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, sizeof(struct other_val) - 4),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 9 },
-       .result = REJECT,
-       .errstr = "invalid access to map value, value_size=16 off=12 size=8",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via const imm): out-of-bound 2",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -4),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 9 },
-       .result = REJECT,
-       .errstr = "invalid access to map value, value_size=16 off=-4 size=8",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via const reg)",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, offsetof(struct other_val, bar)),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 10 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via const reg): out-of-bound 1",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, sizeof(struct other_val) - 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 10 },
-       .result = REJECT,
-       .errstr = "invalid access to map value, value_size=16 off=12 size=8",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via const reg): out-of-bound 2",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_MOV64_IMM(BPF_REG_3, -4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 10 },
-       .result = REJECT,
-       .errstr = "invalid access to map value, value_size=16 off=-4 size=8",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via variable)",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JGT, BPF_REG_3, offsetof(struct other_val, bar), 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 11 },
-       .result = ACCEPT,
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via variable): no max check",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 10 },
-       .result = REJECT,
-       .errstr = "R2 unbounded memory access, make sure to bounds check any such access",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},
-{
-       "map helper access to adjusted map (via variable): wrong max check",
-       .insns = {
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
-       BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
-       BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
-       BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
-       BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
-       BPF_JMP_IMM(BPF_JGT, BPF_REG_3, offsetof(struct other_val, bar) + 1, 4),
-       BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3),
-       BPF_LD_MAP_FD(BPF_REG_1, 0),
-       BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
-       BPF_EXIT_INSN(),
-       },
-       .fixup_map_hash_16b = { 3, 11 },
-       .result = REJECT,
-       .errstr = "invalid access to map value, value_size=16 off=9 size=8",
-       .prog_type = BPF_PROG_TYPE_TRACEPOINT,
-},