Skip to contentSkip to conversation

gve: fix frag_list chaining

PATCH Applied Eric Dumazet 3 participants 3 messages Aug 31, 2023 – Sep 4, 2023

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

PATCH 1/1 gve: fix frag_list chaining

gve_rx_append_frags() is able to build skbs chained with frag_list, like GRO engine.

Problem is that shinfo->frag_list should only be used for the head of the chain.

All other links should use skb->next pointer.

Otherwise, built skbs are not valid and can cause crashes.

Equivalent code in GRO (skb_gro_receive()) is:

    if (NAPI_GRO_CB(p)->last == p)
        skb_shinfo(p)->frag_list = skb;
    else
        NAPI_GRO_CB(p)->last->next = skb;
    NAPI_GRO_CB(p)->last = skb;
Fixes 9b8dd5e5ea48 ("gve: DQO: Add RX path")
Cc Bailey Forrest <[email protected]>
Cc Willem de Bruijn <[email protected]>
Cc Catherine Sullivan <[email protected]>
---
 drivers/net/ethernet/google/gve/gve_rx_dqo.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_rx_dqo.c +4 -1
index ea0e38b4d9e9f6c41441729d6ae5693186f03040..f281e42a7ef9680e2049a185782a37d402c7f886 100644
@@ -570,7 +570,10 @@ static int gve_rx_append_frags(struct napi_struct *napi,
 		if (!skb)
 			return -1;
 
-		skb_shinfo(rx->ctx.skb_tail)->frag_list = skb;
+		if (rx->ctx.skb_tail == rx->ctx.skb_head)
+			skb_shinfo(rx->ctx.skb_head)->frag_list = skb;
+		else
+			rx->ctx.skb_tail->next = skb;
 		rx->ctx.skb_tail = skb;
 		num_frags = 0;
 	}
Signature · 1 line
2.42.0.283.g2d96d420d3-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Eric Dumazet

gve_rx_append_frags() is able to build skbs chained with frag_list, like GRO engine.

Problem is that shinfo->frag_list should only be used for the head of the chain.

All other links should use skb->next pointer.

Otherwise, built skbs are not valid and can cause crashes.

Equivalent code in GRO (skb_gro_receive()) is:

    if (NAPI_GRO_CB(p)->last == p)
        skb_shinfo(p)->frag_list = skb;
    else
        NAPI_GRO_CB(p)->last->next = skb;
    NAPI_GRO_CB(p)->last = skb;
Quoted 9 lines
Fixes 9b8dd5e5ea48 ("gve: DQO: Add RX path")
Cc Bailey Forrest <[email protected]>
Cc Willem de Bruijn <[email protected]>
Cc Catherine Sullivan <[email protected]>
---
 drivers/net/ethernet/google/gve/gve_rx_dqo.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Thu, 31 Aug 2023 21:38:12 +0000 you wrote:

gve_rx_append_frags() is able to build skbs chained with frag_list, like GRO engine.

Problem is that shinfo->frag_list should only be used for the head of the chain.

All other links should use skb->next pointer.

[...]

Here is the summary with links:
- [net] gve: fix frag_list chaining

    https://git.kernel.org/netdev/net/c/817c7cd2043a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html