Skip to content

Commit c559d49

Browse files
committed
supertest
1 parent 2756aaf commit c559d49

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

tools/testing/selftests/bpf/progs/verifier_live_stack.c

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ __msg("22: (95) exit")
312312
__msg("(9,15) frame 0 insn 20 +written -8")
313313
__msg("(9,15) live stack update done in 2 iterations")
314314
__msg("14: (95) exit")
315-
__msg("(0) frame 0 insn 13 +live -16")
315+
__msg("(0) frrame 0 insn 13 +live -16")
316316
__naked unsigned long caller_stack_write_tail_call(void)
317317
{
318318
asm volatile (
@@ -341,6 +341,9 @@ static __used __naked unsigned long write_tail_call(void)
341341
{
342342
asm volatile (
343343
"r6 = r2;"
344+
"r7 = r1;"
345+
"call %[bpf_get_prandom_u32];"
346+
"r1 = r7;"
344347
"r2 = %[map_array] ll;"
345348
"r3 = 0;"
346349
"call %[bpf_tail_call];"
@@ -349,6 +352,65 @@ static __used __naked unsigned long write_tail_call(void)
349352
"exit;"
350353
:
351354
: __imm(bpf_tail_call),
355+
__imm(bpf_get_prandom_u32),
356+
__imm_addr(map_array)
357+
: __clobber_all);
358+
}
359+
360+
SEC("socket")
361+
__log_level(2)
362+
__msg("19: (85) call bpf_tail_call#12")
363+
__msg("(0) frame 0 insn 1 +written -8")
364+
__msg("(0) live stack update done in 2 iterations")
365+
__msg("14: (95) exit")
366+
__msg("(0) frame 0 insn 13 +live -8")
367+
__msg("(0) live stack update done in 2 iterations")
368+
__msg("22: (95) exit")
369+
__msg("(9,15) frame 0 insn 20 +written -8")
370+
__msg("(9,15) live stack update done in 2 iterations")
371+
__msg("14: (95) exit")
372+
__msg("(0) frrame 0 insn 13 +live -16")
373+
__naked unsigned long caller_stack_write_notail_call(void)
374+
{
375+
asm volatile (
376+
"r6 = r1;"
377+
"*(u64 *)(r10 - 8) = -8;"
378+
"call %[bpf_get_prandom_u32];"
379+
"if r0 != 42 goto 1f;"
380+
"goto 2f;"
381+
"1:"
382+
"*(u64 *)(r10 - 8) = -1024;"
383+
"2:"
384+
"r1 = r6;"
385+
"r2 = r10;"
386+
"r2 += -8;"
387+
"call write_notail_call;"
388+
"r1 = *(u64 *)(r10 - 8);"
389+
"r2 = r10;"
390+
"r2 += r1;"
391+
"r0 = *(u64 *)(r2 + 0);"
392+
"exit;"
393+
:: __imm(bpf_get_prandom_u32)
394+
: __clobber_all);
395+
}
396+
397+
static __used __naked unsigned long write_notail_call(void)
398+
{
399+
asm volatile (
400+
"r6 = r2;"
401+
"r7 = r1;"
402+
"call %[bpf_get_prandom_u32];"
403+
"r1 = r7;"
404+
"if r0 != 42 goto 3f;"
405+
"call %[bpf_get_prandom_u32];"
406+
"exit;"
407+
"3:"
408+
"*(u64 *)(r6 + 0) = -16;"
409+
"r0 = 0;"
410+
"exit;"
411+
:
412+
: __imm(bpf_tail_call),
413+
__imm(bpf_get_prandom_u32),
352414
__imm_addr(map_array)
353415
: __clobber_all);
354416
}

0 commit comments

Comments
 (0)