 tcp: fix skb_copy_ubufs() vs BIG TCP · gregkh/linux@3c77a37 · 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 3c77a37 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 074df40 commit 3c77a37 Copy full SHA for 3c77a37 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 @@ -1608,7 +1608,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1608 1608 { 1609 1609 int num_frags = skb_shinfo ( skb ) -&gt; nr_frags ; 1610 1610 struct page * page , * head = NULL ; 1611 - int i , new_frags ; 1611 + int i , order , psize , new_frags ; 1612 1612 u32 d_off ; 1613 1613 1614 1614 if ( skb_shared ( skb ) || skb_unclone ( skb , gfp_mask )) @@ -1617,9 +1617,17 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1617 1617 if (! num_frags ) 1618 1618 goto release ; 1619 1619 1620 - new_frags = ( __skb_pagelen ( skb ) + PAGE_SIZE - 1 ) &gt;&gt; PAGE_SHIFT ; 1620 + /* We might have to allocate high order pages, so compute what minimum 1621 + * page order is needed. 1622 + */ 1623 + order = 0 ; 1624 + while (( PAGE_SIZE &lt;&lt; order ) * MAX_SKB_FRAGS &lt; __skb_pagelen ( skb )) 1625 + order ++ ; 1626 + psize = ( PAGE_SIZE &lt;&lt; order ); 1627 + 1628 + new_frags = ( __skb_pagelen ( skb ) + psize - 1 ) &gt;&gt; ( PAGE_SHIFT + order ); 1621 1629 for ( i = 0 ; i &lt; new_frags ; i ++ ) { 1622 - page = alloc_page ( gfp_mask ); 1630 + page = alloc_pages ( gfp_mask | __GFP_COMP , order ); 1623 1631 if (! page ) { 1624 1632 while ( head ) { 1625 1633 struct page * next = ( struct page * ) page_private ( head ); @@ -1646,11 +1654,11 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1646 1654 vaddr = kmap_atomic ( p ); 1647 1655 1648 1656 while ( done &lt; p_len ) { 1649 - if ( d_off == PAGE_SIZE ) { 1657 + if ( d_off == psize ) { 1650 1658 d_off = 0 ; 1651 1659 page = ( struct page * ) page_private ( page ); 1652 1660 } 1653 - copy = min_t ( u32 , PAGE_SIZE - d_off , p_len - done ); 1661 + copy = min_t ( u32 , psize - d_off , p_len - done ); 1654 1662 memcpy ( page_address ( page ) + d_off , 1655 1663 vaddr + p_off + done , copy ); 1656 1664 done += copy ; @@ -1666,7 +1674,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1666 1674 1667 1675 /* skb frags point to kernel buffers */ 1668 1676 for ( i = 0 ; i &lt; new_frags - 1 ; i ++ ) { 1669 - __skb_fill_page_desc ( skb , i , head , 0 , PAGE_SIZE ); 1677 + __skb_fill_page_desc ( skb , i , head , 0 , psize ); 1670 1678 head = ( struct page * ) page_private ( head ); 1671 1679 } 1672 1680 __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. 