Skip to contentSkip to conversation

i40e_rx_buffer_flip should not be called for redirected xsk copy mode

Intel-wired-lan Li 3 participants 6 messages Jul 2, 2020 – Jul 16, 2020

Subsystems (3)
lore
Share & tools
lore

Li

#0 lore raw

Hi:

i40e_rx_buffer_flip to xsk copy mode can lead to data corruption, like the following flow:

1. first skb is not for xsk, and forwarded to another device or socket queue
2. seconds skb is for xsk, copy data to xsk memory, and page of skb->data is released
3. rx_buff is reusable since only first skb is in it, but i40e_rx_buffer_flip will make that page_offset is set to first skb data
4. then reuse rx buffer, first skb which still is living will be corrupted.

-Li RongQing

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20200702/810347e7/attachment.html>

#1 lore raw

Thank you RongQing for reporting this. I will take a look at it and produce a patch.

/Magnus

Quoted 27 lines · Li,Rongqing

Hi:

i40e_rx_buffer_flip to xsk copy mode can lead to data corruption, like the following flow:

1. first skb is not for xsk, and forwarded to another device or socket queue

2. seconds skb is for xsk, copy data to xsk memory, and page of skb->data is released

3. rx_buff is reusable since only first skb is in it, but i40e_rx_buffer_flip will make that page_offset is set to first skb data

4. then reuse rx buffer, first skb which still is living will be corrupted.

-Li RongQing

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

#2 lore raw
Quoted 12 lines

-----邮件原件-----
发件人: Magnus Karlsson [mailto:[email protected]]
发送时间: 2020年7月6日 14:13
收件人: Li,Rongqing <[email protected]>
抄送: intel-wired-lan <[email protected]>; Björn Töpel <[email protected]>; Karlsson, Magnus <[email protected]>; Netdev <[email protected]>
主题: Re: [Intel-wired-lan] [bug ?] i40e_rx_buffer_flip should not be called for redirected xsk copy mode

Quoted 4 lines

Thank you RongQing for reporting this. I will take a look at it and produce a patch.

/Magnus

Thanks, and ixgbevf/ixgbe have same issue.

drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
drivers/net/ethernet/intel/i40e/i40e_txrx.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

I have a RFC, it maybe not better due to adding a new variable
http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/

or check memory type

drivers/net/ethernet/intel/i40e/i40e_txrx.c +3 -1
index b3836092c327..f41664e0c84e 100644
@@ -2394,7 +2394,9 @@ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget)
 
                        if (xdp_res & (I40E_XDP_TX | I40E_XDP_REDIR)) {
                                xdp_xmit |= xdp_res;
-                               i40e_rx_buffer_flip(rx_ring, rx_buffer, size);
+
+                               if (xdp->rxq->mem.type != MEM_TYPE_XSK_BUFF_POOL)
+                                       i40e_rx_buffer_flip(rx_ring, rx_buffer, size);
                        } else {
                                rx_buffer->pagecnt_bias++;
                        }

Whether, like to see your patch

-Li RongQing

#3 lore raw
In reply to Magnus Karlsson
Quoted 29 lines

-----????-----
???: Li,Rongqing
????: 2020?7?6? 14:38
???: 'Magnus Karlsson' <[email protected]>
??: intel-wired-lan <[email protected]>; Bj?rn T?pel <[email protected]>; Karlsson, Magnus <[email protected]>; Netdev <[email protected]>
??: ??: [Intel-wired-lan] [bug ?] i40e_rx_buffer_flip should not be called for redirected xsk copy mode

Quoted 14 lines

-----????-----
???: Magnus Karlsson [mailto:magnus.karlsson at gmail.com] ????: 2020?7?6? 14:13
???: Li,Rongqing <[email protected]>
??: intel-wired-lan <[email protected]>; Bj?rn T?pel <[email protected]>; Karlsson, Magnus <[email protected]>; Netdev <[email protected]>
??: Re: [Intel-wired-lan] [bug ?] i40e_rx_buffer_flip should not be called for redirected xsk copy mode

Thank you RongQing for reporting this. I will take a look at it and produce a patch.

/Magnus

Ping

-Li

#4 lore raw
Quoted 25 lines · Li,Rongqing
Quoted 25 lines

-----????-----
???: Li,Rongqing
????: 2020?7?6? 14:38
???: 'Magnus Karlsson' <[email protected]>
??: intel-wired-lan <[email protected]>; Bj?rn T?pel <[email protected]>; Karlsson, Magnus <[email protected]>; Netdev <[email protected]>
??: ??: [Intel-wired-lan] [bug ?] i40e_rx_buffer_flip should not be called for redirected xsk copy mode

Quoted 10 lines

-----????-----
???: Magnus Karlsson [mailto:magnus.karlsson at gmail.com] ????: 2020?7?6? 14:13
???: Li,Rongqing <[email protected]>
??: intel-wired-lan <[email protected]>; Bj?rn T?pel <[email protected]>; Karlsson, Magnus <[email protected]>; Netdev <[email protected]>
??: Re: [Intel-wired-lan] [bug ?] i40e_rx_buffer_flip should not be called for redirected xsk copy mode

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

Thank you RongQing for reporting this. I will take a look at it and produce a patch.

/Magnus

Ping

My apologies RongQing, but it is taking longer than expected due to key people being on vacation during this summer period. We are debating weather the simple fix you provided covers all cases. Hopefully it does, but we just want to make sure. The fix is needed in four drivers: the ones you mention plus ice.

/Magnus

Quoted 2 lines

-Li

#5 lore raw
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

Thank you RongQing for reporting this. I will take a look at it and produce a patch.

/Magnus

Ping

Quoted 7 lines

My apologies RongQing, but it is taking longer than expected due to key people being on vacation during this summer period. We are debating weather the simple fix you provided covers all cases.
Hopefully it does, but we just want to make sure. The fix is needed in four
drivers: the ones you mention plus ice.

/Magnus

If my RFC patch is suitable for this bug, I will resend it.

should I send four patches for four drivers, or should I send one patch for them?

Thanks

-Li