Alexei Starovoitov 1b9b69ecb3 bpf: teach verifier to recognize imm += ptr pattern
Humans don't write C code like:
  u8 *ptr = skb->data;
  int imm = 4;
  imm += ptr;
but from llvm backend point of view 'imm' and 'ptr' are registers and
imm += ptr may be preferred vs ptr += imm depending which register value
will be used further in the code, while verifier can only recognize ptr += imm.
That caused small unrelated changes in the C code of the bpf program to
trigger rejection by the verifier. Therefore teach the verifier to recognize
both ptr += imm and imm += ptr.
For example:
when R6=pkt(id=0,off=0,r=62) R7=imm22
after r7 += r6 instruction
will be R6=pkt(id=0,off=0,r=62) R7=pkt(id=0,off=22,r=62)

Fixes: 969bf05eb3ce ("bpf: direct packet access")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-05-20 19:53:03 -04:00
..
2015-12-04 22:46:25 +01:00
2015-04-11 22:27:55 -04:00
2015-11-19 17:51:48 +01:00
2016-01-22 18:04:28 -05:00
2016-04-04 09:46:47 -04:00
2016-02-08 11:25:39 -05:00
2014-08-08 15:57:18 -07:00
2015-12-14 14:54:37 -05:00
2016-05-12 11:05:27 -04:00
2015-04-12 21:03:31 +02:00
2015-11-23 09:44:58 +01:00
2016-04-28 19:34:04 -07:00
2016-03-22 15:36:02 -07:00
2016-03-22 15:36:02 -07:00
2016-02-16 13:04:58 -05:00
2015-01-17 10:02:23 +13:00
2016-01-22 18:04:28 -05:00
2016-03-01 20:36:56 +01:00