bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
authorDaniel Borkmann <[email protected]>
Tue, 19 Jun 2018 21:33:54 +0000 (14:33 -0700)
committerDavid S. Miller <[email protected]>
Tue, 19 Jun 2018 22:24:28 +0000 (07:24 +0900)
commitc51818d5b793302b0923ade9856574ac28b9333b
tree06e0cd81581c6c4f0e64bb051b64cea9d454357a
parentd563e7a2ffd6275c195fe264e6cc8886eae877c5
bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize

Using skb_reserve(skb, I40E_SKB_PAD + (xdp->data - xdp->data_hard_start))
is clearly wrong since I40E_SKB_PAD already points to the offset where
the original xdp->data was sitting since xdp->data_hard_start is defined
as xdp->data - i40e_rx_offset(rx_ring) where latter offsets to I40E_SKB_PAD
when build skb is used.

However, also before cc5b114dcf98 ("bpf, i40e: add meta data support")
this seems broken since bpf_xdp_adjust_head() helper could have been used
to alter headroom and enlarge / shrink the frame and with that the assumption
that the xdp->data remains unchanged does not hold and would push a bogus
packet to upper stack.

ixgbe got this right in 924708081629 ("ixgbe: add XDP support for pass and
drop actions"). In any case, fix it by removing the I40E_SKB_PAD from both
skb_reserve() and truesize calculation.

Fixes: cc5b114dcf98 ("bpf, i40e: add meta data support")
Fixes: 0c8493d90b6b ("i40e: add XDP support for pass and drop actions")
Reported-by: Keith Busch <[email protected]>
Reported-by: Toshiaki Makita <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Cc: Björn Töpel <[email protected]>
Cc: John Fastabend <[email protected]>
Tested-by: Keith Busch <[email protected]>
Acked-by: John Fastabend <[email protected]>
Acked-by: Alexander Duyck <[email protected]>
Signed-off-by: Jeff Kirsher <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/intel/i40e/i40e_txrx.c