diff options
Diffstat (limited to 'tools/testing/selftests/bpf/test_verifier.c')
| -rw-r--r-- | tools/testing/selftests/bpf/test_verifier.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index c03542c417db..353d17015641 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
| @@ -6487,6 +6487,50 @@ static struct bpf_test tests[] = { | |||
| 6487 | .result = REJECT, | 6487 | .result = REJECT, |
| 6488 | .prog_type = BPF_PROG_TYPE_LWT_IN, | 6488 | .prog_type = BPF_PROG_TYPE_LWT_IN, |
| 6489 | }, | 6489 | }, |
| 6490 | { | ||
| 6491 | "liveness pruning and write screening", | ||
| 6492 | .insns = { | ||
| 6493 | /* Get an unknown value */ | ||
| 6494 | BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 0), | ||
| 6495 | /* branch conditions teach us nothing about R2 */ | ||
| 6496 | BPF_JMP_IMM(BPF_JGE, BPF_REG_2, 0, 1), | ||
| 6497 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 6498 | BPF_JMP_IMM(BPF_JGE, BPF_REG_2, 0, 1), | ||
| 6499 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 6500 | BPF_EXIT_INSN(), | ||
| 6501 | }, | ||
| 6502 | .errstr = "R0 !read_ok", | ||
| 6503 | .result = REJECT, | ||
| 6504 | .prog_type = BPF_PROG_TYPE_LWT_IN, | ||
| 6505 | }, | ||
| 6506 | { | ||
| 6507 | "varlen_map_value_access pruning", | ||
| 6508 | .insns = { | ||
| 6509 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 6510 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 6511 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 6512 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 6513 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 6514 | BPF_FUNC_map_lookup_elem), | ||
| 6515 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), | ||
| 6516 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 0), | ||
| 6517 | BPF_MOV32_IMM(BPF_REG_2, MAX_ENTRIES), | ||
| 6518 | BPF_JMP_REG(BPF_JSGT, BPF_REG_2, BPF_REG_1, 1), | ||
| 6519 | BPF_MOV32_IMM(BPF_REG_1, 0), | ||
| 6520 | BPF_ALU32_IMM(BPF_LSH, BPF_REG_1, 2), | ||
| 6521 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 6522 | BPF_JMP_IMM(BPF_JA, 0, 0, 0), | ||
| 6523 | BPF_ST_MEM(BPF_DW, BPF_REG_0, 0, | ||
| 6524 | offsetof(struct test_val, foo)), | ||
| 6525 | BPF_EXIT_INSN(), | ||
| 6526 | }, | ||
| 6527 | .fixup_map2 = { 3 }, | ||
| 6528 | .errstr_unpriv = "R0 leaks addr", | ||
| 6529 | .errstr = "R0 unbounded memory access", | ||
| 6530 | .result_unpriv = REJECT, | ||
| 6531 | .result = REJECT, | ||
| 6532 | .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, | ||
| 6533 | }, | ||
| 6490 | }; | 6534 | }; |
| 6491 | 6535 | ||
| 6492 | static int probe_filter_length(const struct bpf_insn *fp) | 6536 | static int probe_filter_length(const struct bpf_insn *fp) |
