Skip to contentSkip to conversation

i40e/i40evf: proper update of the page_offset field

PATCH In review Björn Töpel 4 participants 4 messages May 15, 2017 – May 25, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i40e/i40evf: proper update of the page_offset field

From: Bj?rn T?pel <[email protected]>

In f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames") i40e_build_skb updates the page_offset field with an incorrect offset, which can lead to data corruption. This patch updates page_offset correctly, by properly setting truesize.

Note that the bug only appears on architectures where PAGE_SIZE is 8192 or larger.

Fixes f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 3 ++-
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +2 -1
index 29321a6167a6..cd894f4023b1 100644
@@ -1854,7 +1854,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 #if (PAGE_SIZE < 8192)
 	unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = SKB_DATA_ALIGN(size);
+	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+				SKB_DATA_ALIGN(I40E_SKB_PAD + size);
 #endif
 	struct sk_buff *skb;
 
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +2 -1
index dfe241a12ad0..12b02e530503 100644
@@ -1190,7 +1190,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 #if (PAGE_SIZE < 8192)
 	unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = SKB_DATA_ALIGN(size);
+	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+				SKB_DATA_ALIGN(I40E_SKB_PAD + size);
 #endif
 	struct sk_buff *skb;
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 7 lines · Björn Töpel

From: Björn Töpel <[email protected]>

In f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames") i40e_build_skb updates the page_offset field with an incorrect offset, which can lead to data corruption. This patch updates page_offset correctly, by properly setting truesize.

Quoted 5 lines

Note that the bug only appears on architectures where PAGE_SIZE is 8192 or larger.

Fixes f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")

I tested the fix and it solves the problem for me! Thank you!

Quoted 36 lines
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 3 ++-
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +2 -1
index 29321a6167a6..cd894f4023b1 100644
@@ -1854,7 +1854,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 #if (PAGE_SIZE < 8192)
 	unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = SKB_DATA_ALIGN(size);
+	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+				SKB_DATA_ALIGN(I40E_SKB_PAD + size);
 #endif
 	struct sk_buff *skb;
 
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +2 -1
index dfe241a12ad0..12b02e530503 100644
@@ -1190,7 +1190,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 #if (PAGE_SIZE < 8192)
 	unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = SKB_DATA_ALIGN(size);
+	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+				SKB_DATA_ALIGN(I40E_SKB_PAD + size);
 #endif
 	struct sk_buff *skb;
 
Signature · 1 line
2.11.0
Acked-by on v2 1/1
#2 lore raw
In reply to Björn Töpel
Quoted 7 lines · Bj?rn T?pel

From: Bj?rn T?pel <[email protected]>

In f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames") i40e_build_skb updates the page_offset field with an incorrect offset, which can lead to data corruption. This patch updates page_offset correctly, by properly setting truesize.

Quoted 5 lines

Note that the bug only appears on architectures where PAGE_SIZE is 8192 or larger.

Fixes f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
Quoted 33 lines
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 3 ++-
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +2 -1
index 29321a6167a6..cd894f4023b1 100644
@@ -1854,7 +1854,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 #if (PAGE_SIZE < 8192)
 	unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = SKB_DATA_ALIGN(size);
+	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+				SKB_DATA_ALIGN(I40E_SKB_PAD + size);
 #endif
 	struct sk_buff *skb;
 
drivers/net/ethernet/intel/i40evf/i40e_txrx.c +2 -1
index dfe241a12ad0..12b02e530503 100644
@@ -1190,7 +1190,8 @@ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring,
 #if (PAGE_SIZE < 8192)
 	unsigned int truesize = i40e_rx_pg_size(rx_ring) / 2;
 #else
-	unsigned int truesize = SKB_DATA_ALIGN(size);
+	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) +
+				SKB_DATA_ALIGN(I40E_SKB_PAD + size);
 #endif
 	struct sk_buff *skb;
 
#3 lore raw

PATCH v2 1/1 i40e/i40evf: proper update of the page_offset field

In reply to Björn Töpel
Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Bj?rn T?pel
Sent: Sunday, May 14, 2017 9:52 PM
To: netdev at vger.kernel.org; intel-wired-lan at lists.osuosl.org
Cc: Topel, Bjorn <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2] i40e/i40evf: proper update of the page_offset field

From: Bj?rn T?pel <[email protected]>

In f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames") i40e_build_skb updates the page_offset field with an incorrect offset, which can lead to data corruption. This patch updates page_offset correctly, by properly setting truesize.

Note that the bug only appears on architectures where PAGE_SIZE is 8192 or larger.

Quoted 6 lines
Fixes f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c   | 3 ++-
 drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)