bpf: Fix test_verifier after introducing resolve_pseudo_ldimm64
Subsystems (5)
PATCH 1/1 bpf: Fix test_verifier after introducing resolve_pseudo_ldimm64
Commit 4976b718c355 ("bpf: Introduce pseudo_btf_id") switched the order of check_subprogs() and resolve_pseudo_ldimm() in the verifier. Now an empty prog and the prog of a single invalid ldimm expect to see the error "last insn is not an exit or jmp" instead, because the check for subprogs comes first. Fix the expection of the error message.
Tested:
# ./test_verifier Summary: 1130 PASSED, 538 SKIPPED, 0 FAILED and the full set of bpf selftests.
--- tools/testing/selftests/bpf/verifier/basic.c | 2 +- tools/testing/selftests/bpf/verifier/ld_imm64.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/verifier/basic.c +1 -1
@@ -2,7 +2,7 @@ "empty prog", .insns = { }, - .errstr = "unknown opcode 00", + .errstr = "last insn is not an exit or jmp", .result = REJECT, }, {
tools/testing/selftests/bpf/verifier/ld_imm64.c +1 -1
@@ -55,7 +55,7 @@ .insns = { BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0), }, - .errstr = "invalid bpf_ld_imm64 insn", + .errstr = "last insn is not an exit or jmp", .result = REJECT, }, {
Signature · 1 line
2.28.0.806.g8561365e88-goog
Quoted 25 lines · Hao Luo
Commit
4976b718c355("bpf: Introducepseudo_btf_id") switched the order ofcheck_subprogs()andresolve_pseudo_ldimm()in the verifier. Now an empty prog and the prog of a single invalid ldimm expect to see the error "last insn is not an exit or jmp" instead, because the check for subprogs comes first. Fix the expection of the error message.Tested:
# ./test_verifier Summary: 1130 PASSED, 538 SKIPPED, 0 FAILED and the full set of bpf selftests.Fixes 4976b718c355 ("bpf: Introduce pseudo_btf_id")Signed-off-by Hao Luo <[email protected]>--- tools/testing/selftests/bpf/verifier/basic.c | 2 +- tools/testing/selftests/bpf/verifier/ld_imm64.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/bpf/verifier/basic.c +0
-0
tools/testing/selftests/bpf/verifier/basic.c line 5
Quoted 5 lines
tools/testing/selftests/bpf/verifier/basic.c +1
-1@@ -2,7 +2,7 @@ "empty prog", .insns = { }, - .errstr = "unknown opcode 00", + .errstr = "last insn is not an exit or jmp",
in this case the new message makes more sense, so this is a good change
tools/testing/selftests/bpf/verifier/ld_imm64.c line 58
Quoted 13 lines
tools/testing/selftests/bpf/verifier/basic.c +0
-0.result = REJECT, }, {tools/testing/selftests/bpf/verifier/ld_imm64.c +1
-1@@ -55,7 +55,7 @@ .insns = { BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0), }, - .errstr = "invalid bpf_ld_imm64 insn", + .errstr = "last insn is not an exit or jmp",
but this completely defeats the purpose of the test; better add BPF_EXIT_INSN() after ldimm64 instruction to actually get to validation of ldimm64
Quoted 6 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +0
-1.result = REJECT, }, { --2.28.0.806.g8561365e88-goog
Quoted 18 lines · Andrii Nakryiko
Quoted 16 lines · Hao Luo
Commit
4976b718c355("bpf: Introducepseudo_btf_id") switched the order ofcheck_subprogs()andresolve_pseudo_ldimm()in the verifier. Now an empty prog and the prog of a single invalid ldimm expect to see the error "last insn is not an exit or jmp" instead, because the check for subprogs comes first. Fix the expection of the error message.Tested:
# ./test_verifier Summary: 1130 PASSED, 538 SKIPPED, 0 FAILED and the full set of bpf selftests.Fixes 4976b718c355 ("bpf: Introduce pseudo_btf_id")Signed-off-by Hao Luo <[email protected]>---
[...]
Quoted 6 lines
Quoted 6 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +0
-0@@ -55,7 +55,7 @@ .insns = {
Quoted 9 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c line 58
Quoted 4 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +1
-1BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0), }, - .errstr = "invalid bpf_ld_imm64 insn", + .errstr = "last insn is not an exit or jmp",but this completely defeats the purpose of the test; better add
BPF_EXIT_INSN()after ldimm64 instruction to actually get to validation of ldimm64
Actually there is already a test (test4) that covers this case. So it makes sense to remove it, I think. I will resend with this change.
Quoted 6 lines
Quoted 6 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +0
-1.result = REJECT, }, { --2.28.0.806.g8561365e88-goog
Quoted 38 lines · Hao Luo
Quoted 18 lines · Andrii Nakryiko
Quoted 16 lines · Hao Luo
Commit
4976b718c355("bpf: Introducepseudo_btf_id") switched the order ofcheck_subprogs()andresolve_pseudo_ldimm()in the verifier. Now an empty prog and the prog of a single invalid ldimm expect to see the error "last insn is not an exit or jmp" instead, because the check for subprogs comes first. Fix the expection of the error message.Tested:
# ./test_verifier Summary: 1130 PASSED, 538 SKIPPED, 0 FAILED and the full set of bpf selftests.Fixes 4976b718c355 ("bpf: Introduce pseudo_btf_id")Signed-off-by Hao Luo <[email protected]>---
[...]
Quoted 6 lines
Quoted 6 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +0
-0@@ -55,7 +55,7 @@ .insns = {Quoted 9 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c line 58
Quoted 4 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +1
-1BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, 0, 0, 0), }, - .errstr = "invalid bpf_ld_imm64 insn", + .errstr = "last insn is not an exit or jmp",but this completely defeats the purpose of the test; better add
BPF_EXIT_INSN()after ldimm64 instruction to actually get to validation of ldimm64
Quoted 2 lines
Actually there is already a test (test4) that covers this case. So it makes sense to remove it, I think. I will resend with this change.
ah, this test validates that half of ldimm64 at the very end won't cause any troubles to verifier... Yeah, I guess now it's pointless because it can never be the very last instruction.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +0
-1.result = REJECT, }, { --2.28.0.806.g8561365e88-goog