diff options
author | Alexei Starovoitov <ast@kernel.org> | 2019-06-15 12:12:22 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-06-19 02:22:52 +0200 |
commit | aeee380ccfc59c05a4c6e8e762fd645c6bdc773a (patch) | |
tree | 62e3dc588583bedd186bca0126e50b50b6ca8762 /tools/testing/selftests/bpf/test_verifier.c | |
parent | eea1c227b9e9bad295e8ef984004a9acf12bb68c (diff) | |
download | linux-aeee380ccfc59c05a4c6e8e762fd645c6bdc773a.tar.gz linux-aeee380ccfc59c05a4c6e8e762fd645c6bdc773a.tar.bz2 linux-aeee380ccfc59c05a4c6e8e762fd645c6bdc773a.zip |
selftests/bpf: fix tests
Fix tests that assumed no loops.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/testing/selftests/bpf/test_verifier.c')
-rw-r--r-- | tools/testing/selftests/bpf/test_verifier.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index cd0248c54e25..93e1d87a343a 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -237,10 +237,10 @@ static void bpf_fill_scale1(struct bpf_test *self) insn[i++] = BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_6, -8 * (k % 64 + 1)); } - /* every jump adds 1 step to insn_processed, so to stay exactly - * within 1m limit add MAX_TEST_INSNS - MAX_JMP_SEQ - 1 MOVs and 1 EXIT + /* is_state_visited() doesn't allocate state for pruning for every jump. + * Hence multiply jmps by 4 to accommodate that heuristic */ - while (i < MAX_TEST_INSNS - MAX_JMP_SEQ - 1) + while (i < MAX_TEST_INSNS - MAX_JMP_SEQ * 4) insn[i++] = BPF_ALU64_IMM(BPF_MOV, BPF_REG_0, 42); insn[i] = BPF_EXIT_INSN(); self->prog_len = i + 1; @@ -269,10 +269,7 @@ static void bpf_fill_scale2(struct bpf_test *self) insn[i++] = BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_6, -8 * (k % (64 - 4 * FUNC_NEST) + 1)); } - /* every jump adds 1 step to insn_processed, so to stay exactly - * within 1m limit add MAX_TEST_INSNS - MAX_JMP_SEQ - 1 MOVs and 1 EXIT - */ - while (i < MAX_TEST_INSNS - MAX_JMP_SEQ - 1) + while (i < MAX_TEST_INSNS - MAX_JMP_SEQ * 4) insn[i++] = BPF_ALU64_IMM(BPF_MOV, BPF_REG_0, 42); insn[i] = BPF_EXIT_INSN(); self->prog_len = i + 1; |