 tcp: fix skb_copy_ubufs() vs BIG TCP · gregkh/linux@9cd62f0 · 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 9cd62f0 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 27d5e46 commit 9cd62f0 Copy full SHA for 9cd62f0 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 @@ -1705,7 +1705,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1705 1705 { 1706 1706 int num_frags = skb_shinfo ( skb ) -&gt; nr_frags ; 1707 1707 struct page * page , * head = NULL ; 1708 - int i , new_frags ; 1708 + int i , order , psize , new_frags ; 1709 1709 u32 d_off ; 1710 1710 1711 1711 if ( skb_shared ( skb ) || skb_unclone ( skb , gfp_mask )) @@ -1714,9 +1714,17 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1714 1714 if (! num_frags ) 1715 1715 goto release ; 1716 1716 1717 - new_frags = ( __skb_pagelen ( skb ) + PAGE_SIZE - 1 ) &gt;&gt; PAGE_SHIFT ; 1717 + /* We might have to allocate high order pages, so compute what minimum 1718 + * page order is needed. 1719 + */ 1720 + order = 0 ; 1721 + while (( PAGE_SIZE &lt;&lt; order ) * MAX_SKB_FRAGS &lt; __skb_pagelen ( skb )) 1722 + order ++ ; 1723 + psize = ( PAGE_SIZE &lt;&lt; order ); 1724 + 1725 + new_frags = ( __skb_pagelen ( skb ) + psize - 1 ) &gt;&gt; ( PAGE_SHIFT + order ); 1718 1726 for ( i = 0 ; i &lt; new_frags ; i ++ ) { 1719 - page = alloc_page ( gfp_mask ); 1727 + page = alloc_pages ( gfp_mask | __GFP_COMP , order ); 1720 1728 if (! page ) { 1721 1729 while ( head ) { 1722 1730 struct page * next = ( struct page * ) page_private ( head ); @@ -1743,11 +1751,11 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1743 1751 vaddr = kmap_atomic ( p ); 1744 1752 1745 1753 while ( done &lt; p_len ) { 1746 - if ( d_off == PAGE_SIZE ) { 1754 + if ( d_off == psize ) { 1747 1755 d_off = 0 ; 1748 1756 page = ( struct page * ) page_private ( page ); 1749 1757 } 1750 - copy = min_t ( u32 , PAGE_SIZE - d_off , p_len - done ); 1758 + copy = min_t ( u32 , psize - d_off , p_len - done ); 1751 1759 memcpy ( page_address ( page ) + d_off , 1752 1760 vaddr + p_off + done , copy ); 1753 1761 done += copy ; @@ -1763,7 +1771,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1763 1771 1764 1772 /* skb frags point to kernel buffers */ 1765 1773 for ( i = 0 ; i &lt; new_frags - 1 ; i ++ ) { 1766 - __skb_fill_page_desc ( skb , i , head , 0 , PAGE_SIZE ); 1774 + __skb_fill_page_desc ( skb , i , head , 0 , psize ); 1767 1775 head = ( struct page * ) page_private ( head ); 1768 1776 } 1769 1777 __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. 