selftests: bpf: add zero extend checks for ALU32 and/or/xor
Subsystems (5)
PATCH 1/1 selftests: bpf: add zero extend checks for ALU32 and/or/xor
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
--- .../selftests/bpf/verifier/basic_instr.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+)
tools/testing/selftests/bpf/verifier/basic_instr.c +39 -0
@@ -132,3 +132,42 @@ .prog_type = BPF_PROG_TYPE_SCHED_CLS, .result = ACCEPT, }, +{ + "and32 reg zero extend check", + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_AND ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"or32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_OR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"xor32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,0 ), +BPF_ALU32_REG (BPF_XOR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +},
Signature · 1 line
2.20.1
Quoted 6 lines · Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
Signed-off-by Björn Töpel <[email protected]>
I think the patch intends for bpf-next, right? The patch itself looks good to me.
Quoted 54 lines
--- .../selftests/bpf/verifier/basic_instr.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+)tools/testing/selftests/bpf/verifier/basic_instr.c +39
-1@@ -132,3 +132,42 @@ .prog_type = BPF_PROG_TYPE_SCHED_CLS, .result = ACCEPT, }, +{ + "and32 reg zero extend check", + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_AND ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"or32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_OR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"xor32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,0 ), +BPF_ALU32_REG (BPF_XOR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, --2.20.1
Quoted 7 lines · Y Song
Quoted 5 lines · Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
Quoted 6 lines
Quoted 1 line
Signed-off-by Björn Töpel <[email protected]>I think the patch intends for bpf-next, right? The patch itself looks good to me.
Acked-by Yonghong Song <[email protected]>
Thank you. Actually, it was intended for the bpf tree, as a test follow up for this [1] fix.
Cheers,
Björn
[1] https://lore.kernel.org/bpf/CAJ+HfNifkxKz8df7gLBuqWA6+t6awrrRK6oW6m1nAYETJD+Vfg@mail.gmail.com/
Quoted 54 lines
Quoted 54 lines
--- .../selftests/bpf/verifier/basic_instr.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+)tools/testing/selftests/bpf/verifier/basic_instr.c +39
-1@@ -132,3 +132,42 @@ .prog_type = BPF_PROG_TYPE_SCHED_CLS, .result = ACCEPT, }, +{ + "and32 reg zero extend check", + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_AND ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"or32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_OR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"xor32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,0 ), +BPF_ALU32_REG (BPF_XOR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, --2.20.1
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Y Song
Quoted 6 lines · Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
Signed-off-by Björn Töpel <[email protected]>
Quoted 7 lines
Quoted 4 lines
I think the patch intends for bpf-next, right? The patch itself looks good to me.
Acked-by Yonghong Song <[email protected]>Thank you. Actually, it was intended for the bpf tree, as a test follow up for this [1] fix.
Then maybe you want to add a Fixes tag and resubmit?
Quoted 61 lines
Cheers,
Björn[1] https://lore.kernel.org/bpf/CAJ+HfNifkxKz8df7gLBuqWA6+t6awrrRK6oW6m1nAYETJD+Vfg@mail.gmail.com/
Quoted 54 lines
Quoted 54 lines
--- .../selftests/bpf/verifier/basic_instr.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+)tools/testing/selftests/bpf/verifier/basic_instr.c +39
-1@@ -132,3 +132,42 @@ .prog_type = BPF_PROG_TYPE_SCHED_CLS, .result = ACCEPT, }, +{ + "and32 reg zero extend check", + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_AND ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"or32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_OR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"xor32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,0 ), +BPF_ALU32_REG (BPF_XOR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, --2.20.1
Quoted 13 lines · Y Song
Quoted 11 lines · Björn Töpel
Quoted 9 lines · Y Song
Quoted 6 lines · Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
Signed-off-by Björn Töpel <[email protected]>
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
I think the patch intends for bpf-next, right? The patch itself looks good to me.
Acked-by Yonghong Song <[email protected]>Thank you. Actually, it was intended for the bpf tree, as a test follow up for this [1] fix.
Then maybe you want to add a Fixes tag and resubmit?
Hmm, I thought that adding tests were OK for non-next. Should the
Fixes: tag for the test reflex the corresponding fixed code (in this case the RV JIT)?
Quoted 61 lines
Quoted 61 lines
Cheers,
Björn[1] https://lore.kernel.org/bpf/CAJ+HfNifkxKz8df7gLBuqWA6+t6awrrRK6oW6m1nAYETJD+Vfg@mail.gmail.com/
Quoted 54 lines
Quoted 54 lines
--- .../selftests/bpf/verifier/basic_instr.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+)tools/testing/selftests/bpf/verifier/basic_instr.c +39
-1@@ -132,3 +132,42 @@ .prog_type = BPF_PROG_TYPE_SCHED_CLS, .result = ACCEPT, }, +{ + "and32 reg zero extend check", + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_AND ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"or32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,-2 ), +BPF_ALU32_REG (BPF_OR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, +{ +"xor32 reg zero extend check" , + .insns = { +BPF_MOV64_IMM (BPF_REG_0 ,-1 ), +BPF_MOV64_IMM (BPF_REG_2 ,0 ), +BPF_ALU32_REG (BPF_XOR ,BPF_REG_0 ,BPF_REG_2 ), +BPF_ALU64_IMM (BPF_RSH ,BPF_REG_0 ,32 ), + BPF_EXIT_INSN(), + }, + .prog_type =BPF_PROG_TYPE_SCHED_CLS , + .result = ACCEPT, + .retval = 0, +}, --2.20.1
Daniel Borkmann
maintainerQuoted 10 lines · Y Song
Quoted 9 lines · Björn Töpel
Quoted 8 lines · Y Song
Quoted 6 lines · Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
Signed-off-by Björn Töpel <[email protected]>
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
I think the patch intends for bpf-next, right? The patch itself looks good to me.
Acked-by Yonghong Song <[email protected]>Thank you. Actually, it was intended for the bpf tree, as a test follow up for this [1] fix.
Then maybe you want to add a Fixes tag and resubmit?
Why would the test case need a fixes tag? It's common practice that we have BPF fixes that we queue to bpf tree along with kselftest test cases related to them. Therefore, applied as well, thanks for following up!
Björn, in my email from the fix, I mentioned we should have test snippets ideally for all of the alu32 insns to not miss something falling through the cracks when JITs get added or changed. If you have some cycles to add the remaining missing ones, that would be much appreciated.
Thanks,
Daniel
Quoted 22 lines · Daniel Borkmann
Quoted 10 lines · Y Song
Quoted 9 lines · Björn Töpel
Quoted 8 lines · Y Song
Quoted 6 lines · Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
Signed-off-by Björn Töpel <[email protected]>Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
I think the patch intends for bpf-next, right? The patch itself looks good to me.
Acked-by Yonghong Song <[email protected]>Thank you. Actually, it was intended for the bpf tree, as a test follow up for this [1] fix.
Then maybe you want to add a Fixes tag and resubmit?
Quoted 8 lines
Why would the test case need a fixes tag? It's common practice that we have BPF fixes that we queue to bpf tree along with kselftest test cases related to them. Therefore, applied as well, thanks for following up!
Björn, in my email from the fix, I mentioned we should have test snippets ideally for all of the alu32 insns to not miss something falling through the cracks when JITs get added or changed. If you have some cycles to add the remaining missing ones, that would be much appreciated.
Björn,
If you don’t have time, I can take this alu32 test case follow up as well.
Regards,
Jiong
Quoted 3 lines
Thanks,
Daniel
Quoted 27 lines · Jiong Wang
Quoted 27 lines · Daniel Borkmann
Quoted 10 lines · Y Song
Quoted 9 lines · Björn Töpel
Quoted 8 lines · Y Song
Quoted 6 lines · Björn Töpel
Add three tests to test_verifier/basic_instr that make sure that the high 32-bits of the destination register is cleared after an ALU32 and/or/xor.
Signed-off-by Björn Töpel <[email protected]>Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
I think the patch intends for bpf-next, right? The patch itself looks good to me.
Acked-by Yonghong Song <[email protected]>Thank you. Actually, it was intended for the bpf tree, as a test follow up for this [1] fix.
Then maybe you want to add a Fixes tag and resubmit?
Why would the test case need a fixes tag? It's common practice that we have BPF fixes that we queue to bpf tree along with kselftest test cases related to them. Therefore, applied as well, thanks for following up!
Quoted 9 lines
Quoted 4 lines
Björn, in my email from the fix, I mentioned we should have test snippets ideally for all of the alu32 insns to not miss something falling through the cracks when JITs get added or changed. If you have some cycles to add the remaining missing ones, that would be much appreciated.
Björn,
If you don’t have time, I can take this alu32 test case follow up as well.
Jiong, that would be great. Thank you. I'd guess it would take much longer for me to do it (gmail.com time vs intel.com time ;-)).
Björn
Quoted 7 lines
Regards,
JiongQuoted 3 lines
Thanks,
Daniel