1 // SPDX-License-Identifier: GPL-2.0
2 /* Converted from tools/testing/selftests/bpf/verifier/int_ptr.c */
5 #include <bpf/bpf_helpers.h>
9 __description("ARG_PTR_TO_LONG uninitialized")
10 __failure __msg("invalid indirect read from stack R4 off -16+0 size 8")
11 __naked void arg_ptr_to_long_uninitialized(void)
14 /* bpf_strtoul arg1 (buf) */ \
18 *(u64*)(r7 + 0) = r0; \
20 /* bpf_strtoul arg2 (buf_len) */ \
22 /* bpf_strtoul arg3 (flags) */ \
24 /* bpf_strtoul arg4 (res) */ \
28 call %[bpf_strtoul]; \
37 __description("ARG_PTR_TO_LONG half-uninitialized")
38 /* in privileged mode reads from uninitialized stack locations are permitted */
39 __success __failure_unpriv
40 __msg_unpriv("invalid indirect read from stack R4 off -16+4 size 8")
42 __naked void ptr_to_long_half_uninitialized(void)
45 /* bpf_strtoul arg1 (buf) */ \
49 *(u64*)(r7 + 0) = r0; \
51 /* bpf_strtoul arg2 (buf_len) */ \
53 /* bpf_strtoul arg3 (flags) */ \
55 /* bpf_strtoul arg4 (res) */ \
57 *(u32*)(r7 + 0) = r0; \
60 call %[bpf_strtoul]; \
69 __description("ARG_PTR_TO_LONG misaligned")
70 __failure __msg("misaligned stack access off (0x0; 0x0)+-20+0 size 8")
71 __naked void arg_ptr_to_long_misaligned(void)
74 /* bpf_strtoul arg1 (buf) */ \
78 *(u64*)(r7 + 0) = r0; \
80 /* bpf_strtoul arg2 (buf_len) */ \
82 /* bpf_strtoul arg3 (flags) */ \
84 /* bpf_strtoul arg4 (res) */ \
87 *(u32*)(r7 + 0) = r0; \
88 *(u64*)(r7 + 4) = r0; \
91 call %[bpf_strtoul]; \
100 __description("ARG_PTR_TO_LONG size < sizeof(long)")
101 __failure __msg("invalid indirect access to stack R4 off=-4 size=8")
102 __naked void to_long_size_sizeof_long(void)
105 /* bpf_strtoul arg1 (buf) */ \
109 *(u64*)(r7 + 0) = r0; \
111 /* bpf_strtoul arg2 (buf_len) */ \
113 /* bpf_strtoul arg3 (flags) */ \
115 /* bpf_strtoul arg4 (res) */ \
117 *(u32*)(r7 + 0) = r0; \
119 /* bpf_strtoul() */ \
120 call %[bpf_strtoul]; \
129 __description("ARG_PTR_TO_LONG initialized")
131 __naked void arg_ptr_to_long_initialized(void)
134 /* bpf_strtoul arg1 (buf) */ \
138 *(u64*)(r7 + 0) = r0; \
140 /* bpf_strtoul arg2 (buf_len) */ \
142 /* bpf_strtoul arg3 (flags) */ \
144 /* bpf_strtoul arg4 (res) */ \
146 *(u64*)(r7 + 0) = r0; \
148 /* bpf_strtoul() */ \
149 call %[bpf_strtoul]; \
157 char _license[] SEC("license") = "GPL";