All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
@ 2018-06-13  9:04 ` Daniel Borkmann
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2018-06-13  9:04 UTC (permalink / raw)
  To: jeffrey.t.kirsher
  Cc: intel-wired-lan, keith.busch, makita.toshiaki, bjorn.topel,
	john.fastabend, netdev, Daniel Borkmann

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 <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>
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 8ffb745..ed6dbcf 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -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;
 #else
 	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
-				SKB_DATA_ALIGN(I40E_SKB_PAD +
-					       (xdp->data_end -
-						xdp->data_hard_start));
+				SKB_DATA_ALIGN(xdp->data_end -
+					       xdp->data_hard_start);
 #endif
 	struct sk_buff *skb;
 
@@ -2124,7 +2123,7 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 		return NULL;
 
 	/* 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);
 	if (metasize)
 		skb_metadata_set(skb, metasize);
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
@ 2018-06-13  9:04 ` Daniel Borkmann
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2018-06-13  9:04 UTC (permalink / raw)
  To: intel-wired-lan

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 <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>
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
index 8ffb745..ed6dbcf 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
@@ -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;
 #else
 	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
-				SKB_DATA_ALIGN(I40E_SKB_PAD +
-					       (xdp->data_end -
-						xdp->data_hard_start));
+				SKB_DATA_ALIGN(xdp->data_end -
+					       xdp->data_hard_start);
 #endif
 	struct sk_buff *skb;
 
@@ -2124,7 +2123,7 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 		return NULL;
 
 	/* 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);
 	if (metasize)
 		skb_metadata_set(skb, metasize);
-- 
2.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
  2018-06-13  9:04 ` [Intel-wired-lan] " Daniel Borkmann
@ 2018-06-13 13:30   ` Keith Busch
  -1 siblings, 0 replies; 8+ messages in thread
From: Keith Busch @ 2018-06-13 13:30 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: jeffrey.t.kirsher, intel-wired-lan, makita.toshiaki, bjorn.topel,
	john.fastabend, netdev

On Wed, Jun 13, 2018 at 11:04:36AM +0200, Daniel Borkmann wrote:
> 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 <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>

Thanks for the quick fix! This works for me.

Tested-by: Keith Busch <keith.busch@linux.intel.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
@ 2018-06-13 13:30   ` Keith Busch
  0 siblings, 0 replies; 8+ messages in thread
From: Keith Busch @ 2018-06-13 13:30 UTC (permalink / raw)
  To: intel-wired-lan

On Wed, Jun 13, 2018 at 11:04:36AM +0200, Daniel Borkmann wrote:
> 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 <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>

Thanks for the quick fix! This works for me.

Tested-by: Keith Busch <keith.busch@linux.intel.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
  2018-06-13  9:04 ` [Intel-wired-lan] " Daniel Borkmann
@ 2018-06-13 16:26   ` John Fastabend
  -1 siblings, 0 replies; 8+ messages in thread
From: John Fastabend @ 2018-06-13 16:26 UTC (permalink / raw)
  To: Daniel Borkmann, jeffrey.t.kirsher
  Cc: intel-wired-lan, keith.busch, makita.toshiaki, bjorn.topel, netdev

On 06/13/2018 02:04 AM, Daniel Borkmann wrote:
> 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 <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>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_txrx.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 

Thanks! I missed this during review.

Acked-by: John Fastabend <john.fastabend@gmail.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
@ 2018-06-13 16:26   ` John Fastabend
  0 siblings, 0 replies; 8+ messages in thread
From: John Fastabend @ 2018-06-13 16:26 UTC (permalink / raw)
  To: intel-wired-lan

On 06/13/2018 02:04 AM, Daniel Borkmann wrote:
> 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 <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>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_txrx.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 

Thanks! I missed this during review.

Acked-by: John Fastabend <john.fastabend@gmail.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Intel-wired-lan] [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
  2018-06-13 16:26   ` [Intel-wired-lan] " John Fastabend
@ 2018-06-13 17:10     ` Alexander Duyck
  -1 siblings, 0 replies; 8+ messages in thread
From: Alexander Duyck @ 2018-06-13 17:10 UTC (permalink / raw)
  To: John Fastabend
  Cc: Daniel Borkmann, Jeff Kirsher, Netdev, Björn Töpel,
	intel-wired-lan, keith.busch, makita.toshiaki

On Wed, Jun 13, 2018 at 9:26 AM, John Fastabend
<john.fastabend@gmail.com> wrote:
> On 06/13/2018 02:04 AM, Daniel Borkmann wrote:
>> 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 <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>
>> ---
>>  drivers/net/ethernet/intel/i40e/i40e_txrx.c | 7 +++----
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>
>
> Thanks! I missed this during review.
>
> Acked-by: John Fastabend <john.fastabend@gmail.com>

Looks good to me. Thanks for taking care of this.

Acked-by: Alexander Duyck <alexander.h.duyck@intel.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Intel-wired-lan] [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize
@ 2018-06-13 17:10     ` Alexander Duyck
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Duyck @ 2018-06-13 17:10 UTC (permalink / raw)
  To: intel-wired-lan

On Wed, Jun 13, 2018 at 9:26 AM, John Fastabend
<john.fastabend@gmail.com> wrote:
> On 06/13/2018 02:04 AM, Daniel Borkmann wrote:
>> 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 <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>
>> ---
>>  drivers/net/ethernet/intel/i40e/i40e_txrx.c | 7 +++----
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>
>
> Thanks! I missed this during review.
>
> Acked-by: John Fastabend <john.fastabend@gmail.com>

Looks good to me. Thanks for taking care of this.

Acked-by: Alexander Duyck <alexander.h.duyck@intel.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-06-13 17:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-13  9:04 [PATCH net/jkirsher] bpf, xdp, i40e: fix i40e_build_skb skb reserve and truesize Daniel Borkmann
2018-06-13  9:04 ` [Intel-wired-lan] " Daniel Borkmann
2018-06-13 13:30 ` Keith Busch
2018-06-13 13:30   ` [Intel-wired-lan] " Keith Busch
2018-06-13 16:26 ` John Fastabend
2018-06-13 16:26   ` [Intel-wired-lan] " John Fastabend
2018-06-13 17:10   ` Alexander Duyck
2018-06-13 17:10     ` Alexander Duyck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.