William Tu 63dfef75ed bpf: enable verifier to add 0 to packet ptr
The patch fixes the case when adding a zero value to the packet
pointer.  The zero value could come from src_reg equals type
BPF_K or CONST_IMM.  The patch fixes both, otherwise the verifer
reports the following error:
  [...]
    R0=imm0,min_value=0,max_value=0
    R1=pkt(id=0,off=0,r=4)
    R2=pkt_end R3=fp-12
    R4=imm4,min_value=4,max_value=4
    R5=pkt(id=0,off=4,r=4)
  269: (bf) r2 = r0     // r2 becomes imm0
  270: (77) r2 >>= 3
  271: (bf) r4 = r1     // r4 becomes pkt ptr
  272: (0f) r4 += r2    // r4 += 0
  addition of negative constant to packet pointer is not allowed

Signed-off-by: William Tu <u9012063@gmail.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-02-06 22:50:04 -05:00
..
2016-12-25 17:21:22 +01:00
2015-11-19 17:51:48 +01:00
2017-01-12 07:01:56 -07:00
2016-12-25 17:21:22 +01:00
2015-11-23 09:44:58 +01:00
2016-12-12 18:55:06 -08:00
2016-02-16 13:04:58 -05:00
2017-01-24 16:26:14 -08:00
2016-05-27 15:26:11 -07:00
2016-03-01 20:36:56 +01:00
2016-12-22 22:58:37 -05:00
2017-01-24 06:23:51 +13:00
2016-09-22 20:00:36 -05:00