Thread (8 messages) 8 messages, 3 authors, 2017-02-03

Re: [PATCH net-next] bpf: fix verifier issue at check_packet_ptr_add

From: Alexei Starovoitov <hidden>
Date: 2017-02-03 06:19:26

On Thu, Feb 02, 2017 at 09:31:06PM -0800, William Tu wrote:
Yes, this is auto-generated. We want to use P4 2016 as front end to
generate ebpf for XDP.
P4 2016 front-end ? is it public? Is there a 2017 version? ;)
just curious.
quoted
The line 272 is r4 += r2
where R4=imm4 and R2=pkt_end
R2 is no longer pkt_end, it's R2 == R0 == 0
269: (bf) r2 = r0
270: (77) r2 >>= 3
271: (bf) r4 = r1
272: (0f) r4 += r2

So at line 272, it's pkt_ptr = pkt_ptr + 0
thus the following fix works for us.
-               if (imm <= 0) {
+               if (imm < 0) {
got it. I forgot that we have:
  if (src_reg->type == CONST_IMM) {
          /* pkt_ptr += reg where reg is known constant */
          imm = src_reg->imm;
          goto add_imm;
  }
and got confused by if (BPF_SRC(insn->code) == BPF_K) bit.
Thanks for explaining!
Could you respin with the extra test for it in the test_verifier.c ?
Since it's a rare case, would be good to keep it working.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help