net: add pskb_may_pull() to skb_gro_receive_list()
Subsystems (2)
PATCH 1/1 net: add pskb_may_pull() to skb_gro_receive_list()
skb_gro_receive_list() calls skb_pull(skb, skb_gro_offset(skb)) without first ensuring the data is in the linear area via pskb_may_pull(). When the skb arrives via napi_gro_frags(), skb_headlen can be 0 (all data in page fragments) while skb_gro_offset is non-zero (after IP+TCP header parsing). The skb_pull() then decrements skb->len by skb_gro_offset but skb->data_len stays unchanged, hitting BUG_ON(skb->len < skb->data_len) in __skb_pull().
The UDP fraglist GRO path already contains this guard at udp_offload.c:749. Adding it to skb_gro_receive_list() itself provides centralized protection for all callers (TCP, UDP, and any future protocols), and ensures the precondition of skb_pull() is satisfied before it is called.
On pskb_may_pull() failure, set NAPI_GRO_CB(skb)->flush = 1 so the skb is not held as a new GRO head and is instead delivered through the normal receive path, matching the UDP handling.
--- net/core/gro.c | 5 +++++ 1 file changed, 5 insertions(+)
net/core/gro.c +5 -0
@@ -232,6 +232,11 @@ int skb_gro_receive_list(struct sk_buff *p, struct sk_buff *skb)if (unlikely (p->len + skb->len >=65536 ))return -E2BIG ; +if (!pskb_may_pull (skb,skb_gro_offset (skb))) { +NAPI_GRO_CB (skb)->flush =1 ; +return -ENOMEM ; + } +if (NAPI_GRO_CB (p)->last == p)skb_shinfo (p)->frag_list = skb;else
Signature · 1 line
2.43.0
Quoted 19 lines · HanQuan
skb_gro_receive_list()callsskb_pull(skb, skb_gro_offset(skb))without first ensuring the data is in the linear area viapskb_may_pull(). When the skb arrives vianapi_gro_frags(),skb_headlencan be 0 (all data in page fragments) whileskb_gro_offsetis non-zero (after IP+TCP header parsing). Theskb_pull()then decrementsskb->lenbyskb_gro_offsetbutskb->data_lenstays unchanged, hittingBUG_ON(skb->len < skb->data_len)in__skb_pull().The UDP fraglist GRO path already contains this guard at udp_offload.c:749. Adding it to
skb_gro_receive_list()itself provides centralized protection for all callers (TCP, UDP, and any future protocols), and ensures the precondition ofskb_pull()is satisfied before it is called.On
pskb_may_pull()failure, set NAPI_GRO_CB(skb)->flush = 1 so the skb is not held as a new GRO head and is instead delivered through the normal receive path, matching the UDP handling.
Quoted 5 lines
Fixes 8d95dc474f85 ("net: add code for TCP fraglist GRO")Reported-by HanQuan <[email protected]>Reported-by MingXuan <[email protected]>Signed-off-by HanQuan <[email protected]>---
Please note that you should not cc [email protected] on patches sent to public lists.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 4 Jun 2026 14:46:25 +0000 you wrote:
skb_gro_receive_list()callsskb_pull(skb, skb_gro_offset(skb))without first ensuring the data is in the linear area viapskb_may_pull(). When the skb arrives vianapi_gro_frags(),skb_headlencan be 0 (all data in page fragments) whileskb_gro_offsetis non-zero (after IP+TCP header parsing). Theskb_pull()then decrementsskb->lenbyskb_gro_offsetbutskb->data_lenstays unchanged, hittingBUG_ON(skb->len < skb->data_len)in__skb_pull().[...]
Here is the summary with links:
- [net] net: add pskb_may_pull() to skb_gro_receive_list()
https://git.kernel.org/netdev/net/c/f2bb34345444
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html