 tcp: fix skb_copy_ubufs() vs BIG TCP · gregkh/linux@7e692df · 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 7e692df Browse files Browse files edumazet authored and davem330 committed tcp: fix skb_copy_ubufs() vs BIG TCP 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; 1 parent 6f75cd1 commit 7e692df Copy full SHA for 7e692df 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 @@ -1758,7 +1758,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1758 1758 { 1759 1759 int num_frags = skb_shinfo ( skb ) -&gt; nr_frags ; 1760 1760 struct page * page , * head = NULL ; 1761 - int i , new_frags ; 1761 + int i , order , psize , new_frags ; 1762 1762 u32 d_off ; 1763 1763 1764 1764 if ( skb_shared ( skb ) || skb_unclone ( skb , gfp_mask )) @@ -1767,9 +1767,17 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1767 1767 if (! num_frags ) 1768 1768 goto release ; 1769 1769 1770 - new_frags = ( __skb_pagelen ( skb ) + PAGE_SIZE - 1 ) &gt;&gt; PAGE_SHIFT ; 1770 + /* We might have to allocate high order pages, so compute what minimum 1771 + * page order is needed. 1772 + */ 1773 + order = 0 ; 1774 + while (( PAGE_SIZE &lt;&lt; order ) * MAX_SKB_FRAGS &lt; __skb_pagelen ( skb )) 1775 + order ++ ; 1776 + psize = ( PAGE_SIZE &lt;&lt; order ); 1777 + 1778 + new_frags = ( __skb_pagelen ( skb ) + psize - 1 ) &gt;&gt; ( PAGE_SHIFT + order ); 1771 1779 for ( i = 0 ; i &lt; new_frags ; i ++ ) { 1772 - page = alloc_page ( gfp_mask ); 1780 + page = alloc_pages ( gfp_mask | __GFP_COMP , order ); 1773 1781 if (! page ) { 1774 1782 while ( head ) { 1775 1783 struct page * next = ( struct page * ) page_private ( head ); @@ -1796,11 +1804,11 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1796 1804 vaddr = kmap_atomic ( p ); 1797 1805 1798 1806 while ( done &lt; p_len ) { 1799 - if ( d_off == PAGE_SIZE ) { 1807 + if ( d_off == psize ) { 1800 1808 d_off = 0 ; 1801 1809 page = ( struct page * ) page_private ( page ); 1802 1810 } 1803 - copy = min_t ( u32 , PAGE_SIZE - d_off , p_len - done ); 1811 + copy = min_t ( u32 , psize - d_off , p_len - done ); 1804 1812 memcpy ( page_address ( page ) + d_off , 1805 1813 vaddr + p_off + done , copy ); 1806 1814 done += copy ; @@ -1816,7 +1824,7 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask) 1816 1824 1817 1825 /* skb frags point to kernel buffers */ 1818 1826 for ( i = 0 ; i &lt; new_frags - 1 ; i ++ ) { 1819 - __skb_fill_page_desc ( skb , i , head , 0 , PAGE_SIZE ); 1827 + __skb_fill_page_desc ( skb , i , head , 0 , psize ); 1820 1828 head = ( struct page * ) page_private ( head ); 1821 1829 } 1822 1830 __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. 