Message ID | 20201111031213.25109-4-alexei.starovoitov@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | cb62d34019d9117bb94de6ed35959449d43d6055 |
Delegated to: | BPF |
Headers | show |
Series | bpf: Pointers beyond packet end. | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | fail | Errors and warnings before: 4 this patch: 4 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | fail | Link |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
Alexei Starovoitov wrote: > From: Alexei Starovoitov <ast@kernel.org> > > Add few assembly tests for packet comparison. > > Tested-by: Jiri Olsa <jolsa@redhat.com> > Signed-off-by: Alexei Starovoitov <ast@kernel.org> > --- > .../testing/selftests/bpf/verifier/ctx_skb.c | 42 +++++++++++++++++++ > 1 file changed, 42 insertions(+) Acked-by: John Fastabend <john.fastabend@gmail.com>
On Tue, Nov 10, 2020 at 07:12:13PM -0800, Alexei Starovoitov wrote: > From: Alexei Starovoitov <ast@kernel.org> > > Add few assembly tests for packet comparison. > > Tested-by: Jiri Olsa <jolsa@redhat.com> > Signed-off-by: Alexei Starovoitov <ast@kernel.org> hi, I'm now getting error when running this test: #347/p pkt_end < pkt taken check Did not run the program (not supported) OK Summary: 1 PASSED, 0 SKIPPED, 0 FAILED it looks like my kernel does not have prog->aux->ops->test_run defined for BPF_PROG_TYPE_SK_SKB for some reason do I miss some config option? I recall running this back in November, so I'm confused ;-) thanks, jirka > --- > .../testing/selftests/bpf/verifier/ctx_skb.c | 42 +++++++++++++++++++ > 1 file changed, 42 insertions(+) > > diff --git a/tools/testing/selftests/bpf/verifier/ctx_skb.c b/tools/testing/selftests/bpf/verifier/ctx_skb.c > index 2e16b8e268f2..2022c0f2cd75 100644 > --- a/tools/testing/selftests/bpf/verifier/ctx_skb.c > +++ b/tools/testing/selftests/bpf/verifier/ctx_skb.c > @@ -1089,3 +1089,45 @@ > .errstr_unpriv = "R1 leaks addr", > .result = REJECT, > }, > +{ > + "pkt > pkt_end taken check", > + .insns = { > + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, // 0. r2 = *(u32 *)(r1 + data_end) > + offsetof(struct __sk_buff, data_end)), > + BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, // 1. r4 = *(u32 *)(r1 + data) > + offsetof(struct __sk_buff, data)), > + BPF_MOV64_REG(BPF_REG_3, BPF_REG_4), // 2. r3 = r4 > + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 42), // 3. r3 += 42 > + BPF_MOV64_IMM(BPF_REG_1, 0), // 4. r1 = 0 > + BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_2, 2), // 5. if r3 > r2 goto 8 > + BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 14), // 6. r4 += 14 > + BPF_MOV64_REG(BPF_REG_1, BPF_REG_4), // 7. r1 = r4 > + BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_2, 1), // 8. if r3 > r2 goto 10 > + BPF_LDX_MEM(BPF_H, BPF_REG_2, BPF_REG_1, 9), // 9. r2 = *(u8 *)(r1 + 9) > + BPF_MOV64_IMM(BPF_REG_0, 0), // 10. r0 = 0 > + BPF_EXIT_INSN(), // 11. exit > + }, > + .result = ACCEPT, > + .prog_type = BPF_PROG_TYPE_SK_SKB, > +}, > +{ > + "pkt_end < pkt taken check", > + .insns = { > + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, // 0. r2 = *(u32 *)(r1 + data_end) > + offsetof(struct __sk_buff, data_end)), > + BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, // 1. r4 = *(u32 *)(r1 + data) > + offsetof(struct __sk_buff, data)), > + BPF_MOV64_REG(BPF_REG_3, BPF_REG_4), // 2. r3 = r4 > + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 42), // 3. r3 += 42 > + BPF_MOV64_IMM(BPF_REG_1, 0), // 4. r1 = 0 > + BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_2, 2), // 5. if r3 > r2 goto 8 > + BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 14), // 6. r4 += 14 > + BPF_MOV64_REG(BPF_REG_1, BPF_REG_4), // 7. r1 = r4 > + BPF_JMP_REG(BPF_JLT, BPF_REG_2, BPF_REG_3, 1), // 8. if r2 < r3 goto 10 > + BPF_LDX_MEM(BPF_H, BPF_REG_2, BPF_REG_1, 9), // 9. r2 = *(u8 *)(r1 + 9) > + BPF_MOV64_IMM(BPF_REG_0, 0), // 10. r0 = 0 > + BPF_EXIT_INSN(), // 11. exit > + }, > + .result = ACCEPT, > + .prog_type = BPF_PROG_TYPE_SK_SKB, > +}, > -- > 2.24.1 >
diff --git a/tools/testing/selftests/bpf/verifier/ctx_skb.c b/tools/testing/selftests/bpf/verifier/ctx_skb.c index 2e16b8e268f2..2022c0f2cd75 100644 --- a/tools/testing/selftests/bpf/verifier/ctx_skb.c +++ b/tools/testing/selftests/bpf/verifier/ctx_skb.c @@ -1089,3 +1089,45 @@ .errstr_unpriv = "R1 leaks addr", .result = REJECT, }, +{ + "pkt > pkt_end taken check", + .insns = { + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, // 0. r2 = *(u32 *)(r1 + data_end) + offsetof(struct __sk_buff, data_end)), + BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, // 1. r4 = *(u32 *)(r1 + data) + offsetof(struct __sk_buff, data)), + BPF_MOV64_REG(BPF_REG_3, BPF_REG_4), // 2. r3 = r4 + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 42), // 3. r3 += 42 + BPF_MOV64_IMM(BPF_REG_1, 0), // 4. r1 = 0 + BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_2, 2), // 5. if r3 > r2 goto 8 + BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 14), // 6. r4 += 14 + BPF_MOV64_REG(BPF_REG_1, BPF_REG_4), // 7. r1 = r4 + BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_2, 1), // 8. if r3 > r2 goto 10 + BPF_LDX_MEM(BPF_H, BPF_REG_2, BPF_REG_1, 9), // 9. r2 = *(u8 *)(r1 + 9) + BPF_MOV64_IMM(BPF_REG_0, 0), // 10. r0 = 0 + BPF_EXIT_INSN(), // 11. exit + }, + .result = ACCEPT, + .prog_type = BPF_PROG_TYPE_SK_SKB, +}, +{ + "pkt_end < pkt taken check", + .insns = { + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, // 0. r2 = *(u32 *)(r1 + data_end) + offsetof(struct __sk_buff, data_end)), + BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, // 1. r4 = *(u32 *)(r1 + data) + offsetof(struct __sk_buff, data)), + BPF_MOV64_REG(BPF_REG_3, BPF_REG_4), // 2. r3 = r4 + BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, 42), // 3. r3 += 42 + BPF_MOV64_IMM(BPF_REG_1, 0), // 4. r1 = 0 + BPF_JMP_REG(BPF_JGT, BPF_REG_3, BPF_REG_2, 2), // 5. if r3 > r2 goto 8 + BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 14), // 6. r4 += 14 + BPF_MOV64_REG(BPF_REG_1, BPF_REG_4), // 7. r1 = r4 + BPF_JMP_REG(BPF_JLT, BPF_REG_2, BPF_REG_3, 1), // 8. if r2 < r3 goto 10 + BPF_LDX_MEM(BPF_H, BPF_REG_2, BPF_REG_1, 9), // 9. r2 = *(u8 *)(r1 + 9) + BPF_MOV64_IMM(BPF_REG_0, 0), // 10. r0 = 0 + BPF_EXIT_INSN(), // 11. exit + }, + .result = ACCEPT, + .prog_type = BPF_PROG_TYPE_SK_SKB, +},