mbox series

[bpf-next,0/3] infer packet range for 'if pkt ==/!= pkt_end' instructions

Message ID 20240108132802.6103-1-eddyz87@gmail.com (mailing list archive)
Headers show
Series infer packet range for 'if pkt ==/!= pkt_end' instructions | expand

Message

Eduard Zingerman Jan. 8, 2024, 1:27 p.m. UTC
As suggested by Maciej Żenczykowski in [1], extend try_match_pkt_pointers
to allow verification of BPF, generated for C code like below:

  if (data + 42 != data_end) { ... }

Also simplify try_match_pkt_pointers to avoid checking both
'pkt <op> pkt_end' and 'pkt_end <op> pkt' conditions,
as suggested by Andrii Nakryiko.

[1] https://lore.kernel.org/bpf/CAHo-Oow5V2u4ZYvzuR8NmJmFDPNYp0pQDJX66rZqUjFHvhx82A@mail.gmail.com/

Eduard Zingerman (3):
  bpf: simplify try_match_pkt_pointers()
  bpf: infer packet range for 'if pkt ==/!= pkt_end' comparisons
  selftests/bpf: test packet range inference for 'if pkt ==/!= pkt_end'

 kernel/bpf/verifier.c                         | 112 ++++----------
 .../bpf/progs/verifier_direct_packet_access.c | 138 ++++++++++++++++++
 2 files changed, 170 insertions(+), 80 deletions(-)