netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net] ixgbe: fix crash in build_skb Rx code path
@ 2018-02-23 20:39 Jeff Kirsher
  2018-02-26 18:47 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Kirsher @ 2018-02-23 20:39 UTC (permalink / raw)
  To: davem
  Cc: Emil Tantilov, netdev, nhorman, sassmann, jogreene, stable,
	Jeff Kirsher

From: Emil Tantilov <emil.s.tantilov@intel.com>

Add check for build_skb enabled ring in ixgbe_dma_sync_frag().
In that case &skb_shinfo(skb)->frags[0] may not always be set which
can lead to a crash. Instead we derive the page offset from skb->data.

Fixes: 42073d91a214
("ixgbe: Have the CPU take ownership of the buffers sooner")
CC: stable <stable@vger.kernel.org>
Reported-by: Ambarish Soman <asoman@redhat.com>
Suggested-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 0da5aa2c8aba..9fc063af233c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -1888,6 +1888,14 @@ static void ixgbe_dma_sync_frag(struct ixgbe_ring *rx_ring,
 				     ixgbe_rx_pg_size(rx_ring),
 				     DMA_FROM_DEVICE,
 				     IXGBE_RX_DMA_ATTR);
+	} else if (ring_uses_build_skb(rx_ring)) {
+		unsigned long offset = (unsigned long)(skb->data) & ~PAGE_MASK;
+
+		dma_sync_single_range_for_cpu(rx_ring->dev,
+					      IXGBE_CB(skb)->dma,
+					      offset,
+					      skb_headlen(skb),
+					      DMA_FROM_DEVICE);
 	} else {
 		struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[0];
 
-- 
2.14.3

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

* Re: [net] ixgbe: fix crash in build_skb Rx code path
  2018-02-23 20:39 [net] ixgbe: fix crash in build_skb Rx code path Jeff Kirsher
@ 2018-02-26 18:47 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-02-26 18:47 UTC (permalink / raw)
  To: jeffrey.t.kirsher
  Cc: emil.s.tantilov, netdev, nhorman, sassmann, jogreene, stable

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Fri, 23 Feb 2018 12:39:41 -0800

> From: Emil Tantilov <emil.s.tantilov@intel.com>
> 
> Add check for build_skb enabled ring in ixgbe_dma_sync_frag().
> In that case &skb_shinfo(skb)->frags[0] may not always be set which
> can lead to a crash. Instead we derive the page offset from skb->data.
> 
> Fixes: 42073d91a214
> ("ixgbe: Have the CPU take ownership of the buffers sooner")
> CC: stable <stable@vger.kernel.org>
> Reported-by: Ambarish Soman <asoman@redhat.com>
> Suggested-by: Alexander Duyck <alexander.h.duyck@intel.com>
> Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
> Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied, thanks Jeff.

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

end of thread, other threads:[~2018-02-26 18:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-23 20:39 [net] ixgbe: fix crash in build_skb Rx code path Jeff Kirsher
2018-02-26 18:47 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).