Skip to contentSkip to conversation

i40e: proper update of the page_offset field

PATCH Superseded Björn Töpel 2 participants 3 messages May 14, 2017 – May 15, 2017

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i40e: 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.

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 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
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;
 
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.

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")

Minor nit. I think i40evf has the same issue and requires the same fix. Can you add that to this patch and resubmit? Otherwise this fix looks good to me.

Quoted 25 lines
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +2 -2
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;
 
--

2.11.0

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw

2017-05-15 2:31 GMT+02:00 Alexander Duyck <[email protected]>:

Quoted 11 lines · Bj?rn T?pel
Quoted 10 lines

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.

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

Quoted 6 lines
Quoted 2 lines
Fixes f8b45b74cc62 ("i40e/i40evf: Use build_skb to build frames")

Minor nit. I think i40evf has the same issue and requires the same fix. Can you add that to this patch and resubmit? Otherwise this fix looks good to me.

Good point. I'll send a v2, that addresses i40evf as well.

Quoted 26 lines
Quoted 26 lines
---
 drivers/net/ethernet/intel/i40e/i40e_txrx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_txrx.c +2 -2
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;
 
--

2.11.0

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan