selftests/bpf: Fix test_verifier after introducing resolve_pseudo_ldimm64
Subsystems (5)
PATCH v2 1/1 selftests/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 expects to see the error "last insn is not an the prog of a single invalid ldimm exit or jmp" instead, because the check for subprogs comes first. It's now pointless to validate that half of ldimm64 won't be the last instruction.
Tested:
# ./test_verifier Summary: 1129 PASSED, 537 SKIPPED, 0 FAILED and the full set of bpf selftests.
---
Changelog in v2:
- Remove the original test_verifier ld_imm64 test4
- Updated commit message.
tools/testing/selftests/bpf/verifier/basic.c | 2 +- .../testing/selftests/bpf/verifier/ld_imm64.c | 24 +++++++------------ 2 files changed, 9 insertions(+), 17 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 +8 -16
@@ -54,21 +54,13 @@ "test5 ld_imm64", .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,0 ), - }, - .errstr = "invalid bpf_ld_imm64 insn", - .result =REJECT , -}, -{ -"test6 ld_imm64" , - .insns = { -BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,0 ),BPF_RAW_INSN (0 ,0 ,0 ,0 ,0 ), BPF_EXIT_INSN(), }, .result =ACCEPT , }, { -"test7 ld_imm64" , +"test6 ld_imm64" , .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,1 ), BPF_RAW_INSN(0, 0, 0, 0, 1),
@@ -78,7 +70,7 @@ .retval = 1, }, { - "test8 ld_imm64", + "test7 ld_imm64", .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,1 ,1 ), BPF_RAW_INSN(0, 0, 0, 0, 1),
@@ -88,7 +80,7 @@ .result = REJECT, }, { - "test9 ld_imm64", + "test8 ld_imm64", .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,1 ), BPF_RAW_INSN(0, 0, 0, 1, 1),
@@ -98,7 +90,7 @@ .result = REJECT, }, { - "test10 ld_imm64", + "test9 ld_imm64", .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,1 ), BPF_RAW_INSN(0, BPF_REG_1, 0, 0, 1),
@@ -108,7 +100,7 @@ .result = REJECT, }, { - "test11 ld_imm64", + "test10 ld_imm64", .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,1 ), BPF_RAW_INSN(0, 0, BPF_REG_1, 0, 1),
@@ -118,7 +110,7 @@ .result = REJECT, }, { - "test12 ld_imm64", + "test11 ld_imm64", .insns = {BPF_MOV64_IMM (BPF_REG_1 ,0 ), BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
@@ -129,7 +121,7 @@ .result = REJECT, }, { - "test13 ld_imm64", + "test12 ld_imm64", .insns = {BPF_MOV64_IMM (BPF_REG_1 ,0 ), BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, 0, BPF_REG_1, 0, 1),
@@ -140,7 +132,7 @@ .result = REJECT, }, { - "test14 ld_imm64: reject 2nd imm != 0", + "test13 ld_imm64: reject 2nd imm != 0", .insns = {BPF_MOV64_IMM (BPF_REG_0 ,0 ), BPF_RAW_INSN(BPF_LD | BPF_IMM | BPF_DW, BPF_REG_1,
Signature · 1 line
2.28.0.806.g8561365e88-goog
Quoted 65 lines · Hao Luo
Commit
4976b718c355("bpf: Introducepseudo_btf_id") switched the order ofcheck_subprogs()andresolve_pseudo_ldimm()in the verifier. Now an empty prog expects to see the error "last insn is not an the prog of a single invalid ldimm exit or jmp" instead, because the check for subprogs comes first. It's now pointless to validate that half of ldimm64 won't be the last instruction.Tested:
# ./test_verifier Summary: 1129 PASSED, 537 SKIPPED, 0 FAILED and the full set of bpf selftests.Fixes 4976b718c355 ("bpf: Introduce pseudo_btf_id")Signed-off-by Hao Luo <[email protected]>---
Changelog in v2:
- Remove the originaltest_verifierld_imm64test4
- Updated commit message.tools/testing/selftests/bpf/verifier/basic.c | 2 +- .../testing/selftests/bpf/verifier/ld_imm64.c | 24 +++++++------------ 2 files changed, 9 insertions(+), 17 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
-9@@ -54,21 +54,13 @@ "test5 ld_imm64", .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,0 ), - }, - .errstr = "invalid bpf_ld_imm64 insn", - .result =REJECT , -}, -{ -"test6 ld_imm64" , - .insns = { -BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,0 ),BPF_RAW_INSN (0 ,0 ,0 ,0 ,0 ), BPF_EXIT_INSN(), }, .result =ACCEPT , }, { -"test7 ld_imm64" , +"test6 ld_imm64" , .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,1 ), BPF_RAW_INSN(0, 0, 0, 0, 1),
tools/testing/selftests/bpf/verifier/ld_imm64.c line 73
Quoted 5 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +1
-1@@ -78,7 +70,7 @@ .retval = 1, }, { - "test8 ld_imm64", + "test7 ld_imm64",
imo that's too much churn to rename all of them.
Just delete one.
Ack. Sent one with just deletion.
Hao
Quoted 75 lines · Alexei Starovoitov
Quoted 65 lines · Hao Luo
Commit
4976b718c355("bpf: Introducepseudo_btf_id") switched the order ofcheck_subprogs()andresolve_pseudo_ldimm()in the verifier. Now an empty prog expects to see the error "last insn is not an the prog of a single invalid ldimm exit or jmp" instead, because the check for subprogs comes first. It's now pointless to validate that half of ldimm64 won't be the last instruction.Tested:
# ./test_verifier Summary: 1129 PASSED, 537 SKIPPED, 0 FAILED and the full set of bpf selftests.Fixes 4976b718c355 ("bpf: Introduce pseudo_btf_id")Signed-off-by Hao Luo <[email protected]>---
Changelog in v2:
- Remove the originaltest_verifierld_imm64test4
- Updated commit message.tools/testing/selftests/bpf/verifier/basic.c | 2 +- .../testing/selftests/bpf/verifier/ld_imm64.c | 24 +++++++------------ 2 files changed, 9 insertions(+), 17 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
-9@@ -54,21 +54,13 @@ "test5 ld_imm64", .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,0 ), - }, - .errstr = "invalid bpf_ld_imm64 insn", - .result =REJECT , -}, -{ -"test6 ld_imm64" , - .insns = { -BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,0 ),BPF_RAW_INSN (0 ,0 ,0 ,0 ,0 ), BPF_EXIT_INSN(), }, .result =ACCEPT , }, { -"test7 ld_imm64" , +"test6 ld_imm64" , .insns = {BPF_RAW_INSN (BPF_LD |BPF_IMM |BPF_DW ,0 ,0 ,0 ,1 ), BPF_RAW_INSN(0, 0, 0, 0, 1),tools/testing/selftests/bpf/verifier/ld_imm64.c line 73
Quoted 5 lines
tools/testing/selftests/bpf/verifier/ld_imm64.c +1
-1@@ -78,7 +70,7 @@ .retval = 1, }, { - "test8 ld_imm64", + "test7 ld_imm64",imo that's too much churn to rename all of them.
Just delete one.