 tcp: fix skb_copy_ubufs() vs BIG TCP · gregkh/linux@7fa93e3 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 676 Star 636 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit 7fa93e3 Browse files Browse files edumazet authored and gregkh committed tcp: fix skb_copy_ubufs() vs BIG TCP [ Upstream commit 7e692df ] David Ahern reported crashes in skb_copy_ubufs() caused by TCP tx zerocopy using hugepages, and skb length bigger than ~68 KB. skb_copy_ubufs() assumed it could copy all payload using up to MAX_SKB_FRAGS order-0 pages. This assumption broke when BIG TCP was able to put up to 512 KB per skb. We did not hit this bug at Google because we use CONFIG_MAX_SKB_FRAGS=45 and limit gso_max_size to 180000. A solution is to use higher order pages if needed. v2: add missing __GFP_COMP, or we leak memory. Fixes: 7c4e983 ("net: allow gso_max_size to exceed 65536") Reported-by: David Ahern &lt;dsahern@kernel.org&gt; Link: https://lore.kernel.org/netdev/c70000f6-baa4-4a05-46d0-4b3e0dc1ccc8@gmail.com/T/ Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt; Cc: Xin Long &lt;lucien.xin@gmail.com&gt; Cc: Willem de Bruijn &lt;willemb@google.com&gt; Cc: Coco Li &lt;lixiaoyan@google.com&gt; Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent 449280a commit 7fa93e3 Copy full SHA for 7fa93e3 1 file changed + 14 - 6 Lines changed: 14 additions &amp; 6 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options net/core skbuff.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ net/core/skbuff.c ‎ Copy file name to clipboard Expand all lines: net/core/skbuff.c + 14 - 6 Lines changed: 14 additions &amp; 6 deletions Original file line number Diff line number Diff line change @@ -1544,7 +1544,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1544 1544 { 1545 1545 int num_frags = skb_shinfo ( skb ) -&gt; nr_frags ; 1546 1546 struct page * page , * head = NULL ; 1547 - int i , new_frags ; 1547 + int i , order , psize , new_frags ; 1548 1548 u32 d_off ; 1549 1549 1550 1550 if ( skb_shared ( skb ) || skb_unclone ( skb , gfp_mask )) @@ -1553,9 +1553,17 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1553 1553 if (! num_frags ) 1554 1554 goto release ; 1555 1555 1556 - new_frags = ( __skb_pagelen ( skb ) + PAGE_SIZE - 1 ) &gt;&gt; PAGE_SHIFT ; 1556 + /* We might have to allocate high order pages, so compute what minimum 1557 + * page order is needed. 1558 + */ 1559 + order = 0 ; 1560 + while (( PAGE_SIZE &lt;&lt; order ) * MAX_SKB_FRAGS &lt; __skb_pagelen ( skb )) 1561 + order ++ ; 1562 + psize = ( PAGE_SIZE &lt;&lt; order ); 1563 + 1564 + new_frags = ( __skb_pagelen ( skb ) + psize - 1 ) &gt;&gt; ( PAGE_SHIFT + order ); 1557 1565 for ( i = 0 ; i &lt; new_frags ; i ++ ) { 1558 - page = alloc_page ( gfp_mask ); 1566 + page = alloc_pages ( gfp_mask | __GFP_COMP , order ); 1559 1567 if (! page ) { 1560 1568 while ( head ) { 1561 1569 struct page * next = ( struct page * ) page_private ( head ); @@ -1582,11 +1590,11 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1582 1590 vaddr = kmap_atomic ( p ); 1583 1591 1584 1592 while ( done &lt; p_len ) { 1585 - if ( d_off == PAGE_SIZE ) { 1593 + if ( d_off == psize ) { 1586 1594 d_off = 0 ; 1587 1595 page = ( struct page * ) page_private ( page ); 1588 1596 } 1589 - copy = min_t ( u32 , PAGE_SIZE - d_off , p_len - done ); 1597 + copy = min_t ( u32 , psize - d_off , p_len - done ); 1590 1598 memcpy ( page_address ( page ) + d_off , 1591 1599 vaddr + p_off + done , copy ); 1592 1600 done += copy ; @@ -1602,7 +1610,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1602 1610 1603 1611 /* skb frags point to kernel buffers */ 1604 1612 for ( i = 0 ; i &lt; new_frags - 1 ; i ++ ) { 1605 - __skb_fill_page_desc ( skb , i , head , 0 , PAGE_SIZE ); 1613 + __skb_fill_page_desc ( skb , i , head , 0 , psize ); 1606 1614 head = ( struct page * ) page_private ( head ); 1607 1615 } 1608 1616 __skb_fill_page_desc ( skb , new_frags - 1 , head , 0 , d_off ); 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 