File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
tools/testing/selftests/bpf/progs Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,35 @@ __naked void access_max_out_of_bound(void)
224
224
: __clobber_all );
225
225
}
226
226
227
+ /* Similar to the test above, but this time check the special case of a
228
+ * zero-sized stack access. We used to have a bug causing crashes for zero-sized
229
+ * out-of-bounds accesses.
230
+ */
231
+ SEC ("socket" )
232
+ __description ("indirect variable-offset stack access, zero-sized, max out of bound" )
233
+ __failure __msg ("invalid variable-offset indirect access to stack R1" )
234
+ __naked void zero_sized_access_max_out_of_bound (void )
235
+ {
236
+ asm volatile (" \
237
+ r0 = 0; \
238
+ /* Fill some stack */ \
239
+ *(u64*)(r10 - 16) = r0; \
240
+ *(u64*)(r10 - 8) = r0; \
241
+ /* Get an unknown value */ \
242
+ r1 = *(u32*)(r1 + 0); \
243
+ r1 &= 63; \
244
+ r1 += -16; \
245
+ /* r1 is now anywhere in [-16,48) */ \
246
+ r1 += r10; \
247
+ r2 = 0; \
248
+ r3 = 0; \
249
+ call %[bpf_probe_read_kernel]; \
250
+ exit; \
251
+ " :
252
+ : __imm (bpf_probe_read_kernel )
253
+ : __clobber_all );
254
+ }
255
+
227
256
SEC ("lwt_in" )
228
257
__description ("indirect variable-offset stack access, min out of bound" )
229
258
__failure __msg ("invalid variable-offset indirect access to stack R2" )
You can’t perform that action at this time.
0 commit comments