forked from Minki/linux
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 beforecc5b114dcf
("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 in9247080816
("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:cc5b114dcf
("bpf, i40e: add meta data support") Fixes:0c8493d90b
("i40e: add XDP support for pass and drop actions") Reported-by: Keith Busch <keith.busch@linux.intel.com> Reported-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Björn Töpel <bjorn.topel@intel.com> Cc: John Fastabend <john.fastabend@gmail.com> Tested-by: Keith Busch <keith.busch@linux.intel.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d563e7a2ff
commit
c51818d5b7
@ -2103,9 +2103,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
|
|||||||
unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
|
unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
|
||||||
#else
|
#else
|
||||||
unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
|
unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
|
||||||
SKB_DATA_ALIGN(I40E_SKB_PAD +
|
SKB_DATA_ALIGN(xdp->data_end -
|
||||||
(xdp->data_end -
|
xdp->data_hard_start);
|
||||||
xdp->data_hard_start));
|
|
||||||
#endif
|
#endif
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
|
||||||
@ -2124,7 +2123,7 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* update pointers within the skb to store the data */
|
/* update pointers within the skb to store the data */
|
||||||
skb_reserve(skb, I40E_SKB_PAD + (xdp->data - xdp->data_hard_start));
|
skb_reserve(skb, xdp->data - xdp->data_hard_start);
|
||||||
__skb_put(skb, xdp->data_end - xdp->data);
|
__skb_put(skb, xdp->data_end - xdp->data);
|
||||||
if (metasize)
|
if (metasize)
|
||||||
skb_metadata_set(skb, metasize);
|
skb_metadata_set(skb, metasize);
|
||||||
|
Loading…
Reference in New Issue
Block a user