2 "PTR_TO_STACK store/load",
4 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
5 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -10),
6 BPF_ST_MEM(BPF_DW
, BPF_REG_1
, 2, 0xfaceb00c),
7 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_1
, 2),
14 "PTR_TO_STACK store/load - bad alignment on off",
16 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
17 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -8),
18 BPF_ST_MEM(BPF_DW
, BPF_REG_1
, 2, 0xfaceb00c),
19 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_1
, 2),
23 .errstr
= "misaligned stack access off (0x0; 0x0)+-8+2 size 8",
26 "PTR_TO_STACK store/load - bad alignment on reg",
28 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
29 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -10),
30 BPF_ST_MEM(BPF_DW
, BPF_REG_1
, 8, 0xfaceb00c),
31 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_1
, 8),
35 .errstr
= "misaligned stack access off (0x0; 0x0)+-10+8 size 8",
38 "PTR_TO_STACK store/load - out of bounds low",
40 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
41 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -80000),
42 BPF_ST_MEM(BPF_DW
, BPF_REG_1
, 8, 0xfaceb00c),
43 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_1
, 8),
47 .errstr
= "invalid stack off=-79992 size=8",
48 .errstr_unpriv
= "R1 stack pointer arithmetic goes out of range",
51 "PTR_TO_STACK store/load - out of bounds high",
53 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
54 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -8),
55 BPF_ST_MEM(BPF_DW
, BPF_REG_1
, 8, 0xfaceb00c),
56 BPF_LDX_MEM(BPF_DW
, BPF_REG_0
, BPF_REG_1
, 8),
60 .errstr
= "invalid stack off=0 size=8",
63 "PTR_TO_STACK check high 1",
65 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
66 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -1),
67 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
68 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
75 "PTR_TO_STACK check high 2",
77 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
78 BPF_ST_MEM(BPF_B
, BPF_REG_1
, -1, 42),
79 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, -1),
86 "PTR_TO_STACK check high 3",
88 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
89 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, 0),
90 BPF_ST_MEM(BPF_B
, BPF_REG_1
, -1, 42),
91 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, -1),
94 .errstr_unpriv
= "R1 stack pointer arithmetic goes out of range",
95 .result_unpriv
= REJECT
,
100 "PTR_TO_STACK check high 4",
102 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
103 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, 0),
104 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
105 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
108 .errstr_unpriv
= "R1 stack pointer arithmetic goes out of range",
109 .errstr
= "invalid stack off=0 size=1",
113 "PTR_TO_STACK check high 5",
115 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
116 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, (1 << 29) - 1),
117 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
118 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
122 .errstr
= "invalid stack off",
125 "PTR_TO_STACK check high 6",
127 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
128 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, (1 << 29) - 1),
129 BPF_ST_MEM(BPF_B
, BPF_REG_1
, SHRT_MAX
, 42),
130 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, SHRT_MAX
),
134 .errstr
= "invalid stack off",
137 "PTR_TO_STACK check high 7",
139 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
140 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, (1 << 29) - 1),
141 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, (1 << 29) - 1),
142 BPF_ST_MEM(BPF_B
, BPF_REG_1
, SHRT_MAX
, 42),
143 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, SHRT_MAX
),
147 .errstr_unpriv
= "R1 stack pointer arithmetic goes out of range",
148 .errstr
= "fp pointer offset",
151 "PTR_TO_STACK check low 1",
153 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
154 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -512),
155 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
156 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
163 "PTR_TO_STACK check low 2",
165 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
166 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -513),
167 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 1, 42),
168 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 1),
171 .result_unpriv
= REJECT
,
172 .errstr_unpriv
= "R1 stack pointer arithmetic goes out of range",
177 "PTR_TO_STACK check low 3",
179 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
180 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -513),
181 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
182 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
185 .errstr_unpriv
= "R1 stack pointer arithmetic goes out of range",
186 .errstr
= "invalid stack off=-513 size=1",
190 "PTR_TO_STACK check low 4",
192 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
193 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, INT_MIN
),
194 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
195 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
199 .errstr
= "math between fp pointer",
202 "PTR_TO_STACK check low 5",
204 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
205 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -((1 << 29) - 1)),
206 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
207 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
211 .errstr
= "invalid stack off",
214 "PTR_TO_STACK check low 6",
216 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
217 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -((1 << 29) - 1)),
218 BPF_ST_MEM(BPF_B
, BPF_REG_1
, SHRT_MIN
, 42),
219 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, SHRT_MIN
),
223 .errstr
= "invalid stack off",
226 "PTR_TO_STACK check low 7",
228 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
229 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -((1 << 29) - 1)),
230 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -((1 << 29) - 1)),
231 BPF_ST_MEM(BPF_B
, BPF_REG_1
, SHRT_MIN
, 42),
232 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, SHRT_MIN
),
236 .errstr_unpriv
= "R1 stack pointer arithmetic goes out of range",
237 .errstr
= "fp pointer offset",
240 "PTR_TO_STACK mixed reg/k, 1",
242 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
243 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -3),
244 BPF_MOV64_IMM(BPF_REG_2
, -3),
245 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_2
),
246 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
247 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
254 "PTR_TO_STACK mixed reg/k, 2",
256 BPF_ST_MEM(BPF_DW
, BPF_REG_10
, -8, 0),
257 BPF_ST_MEM(BPF_DW
, BPF_REG_10
, -16, 0),
258 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
259 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -3),
260 BPF_MOV64_IMM(BPF_REG_2
, -3),
261 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_2
),
262 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
263 BPF_MOV64_REG(BPF_REG_5
, BPF_REG_10
),
264 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_5
, -6),
271 "PTR_TO_STACK mixed reg/k, 3",
273 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
274 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -3),
275 BPF_MOV64_IMM(BPF_REG_2
, -3),
276 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_2
),
277 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
278 BPF_MOV64_REG(BPF_REG_0
, BPF_REG_2
),
287 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
288 BPF_MOV64_IMM(BPF_REG_2
, -3),
289 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_2
),
290 BPF_ST_MEM(BPF_B
, BPF_REG_1
, 0, 42),
291 BPF_LDX_MEM(BPF_B
, BPF_REG_0
, BPF_REG_1
, 0),
294 .result_unpriv
= REJECT
,
295 .errstr_unpriv
= "invalid stack off=0 size=1",
300 "stack pointer arithmetic",
302 BPF_MOV64_IMM(BPF_REG_1
, 4),
303 BPF_JMP_IMM(BPF_JA
, 0, 0, 0),
304 BPF_MOV64_REG(BPF_REG_7
, BPF_REG_10
),
305 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_7
, -10),
306 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_7
, -10),
307 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_7
),
308 BPF_ALU64_REG(BPF_ADD
, BPF_REG_2
, BPF_REG_1
),
309 BPF_ST_MEM(0, BPF_REG_2
, 4, 0),
310 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_7
),
311 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, 8),
312 BPF_ST_MEM(0, BPF_REG_2
, 4, 0),
313 BPF_MOV64_IMM(BPF_REG_0
, 0),