Skip to content

Commit b382b38

Browse files
borkmannintel-lab-lkp
authored andcommitted
bpf: Add loop test case with 32 bit reg comparison against 0
Add a loop test with 32 bit register against 0 immediate: # ./test_verifier 631 torvalds#631/p taken loop with back jump to 1st insn, 2 OK Disassembly: [...] 1b: test %edi,%edi 1d: jne 0x0000000000000014 [...] Pretty much similar to prior "taken loop with back jump to 1st insn" test case just as jmp32 variant. Signed-off-by: Daniel Borkmann <[email protected]>
1 parent a0f03d7 commit b382b38

File tree

1 file changed

+17
-0
lines changed
  • tools/testing/selftests/bpf/verifier

1 file changed

+17
-0
lines changed

tools/testing/selftests/bpf/verifier/loops1.c

+17
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,20 @@
187187
.prog_type = BPF_PROG_TYPE_XDP,
188188
.retval = 55,
189189
},
190+
{
191+
"taken loop with back jump to 1st insn, 2",
192+
.insns = {
193+
BPF_MOV64_IMM(BPF_REG_1, 10),
194+
BPF_MOV64_IMM(BPF_REG_2, 0),
195+
BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 1, 0, 1),
196+
BPF_EXIT_INSN(),
197+
BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_1),
198+
BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 1),
199+
BPF_JMP32_IMM(BPF_JNE, BPF_REG_1, 0, -3),
200+
BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
201+
BPF_EXIT_INSN(),
202+
},
203+
.result = ACCEPT,
204+
.prog_type = BPF_PROG_TYPE_XDP,
205+
.retval = 55,
206+
},

0 commit comments

Comments
 (0)