 tcp: fix a signed-integer-overflow bug in tcp_add_backlog() · gregkh/linux@ec791d8 · 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 ec791d8 Browse files Browse files Lu Wei authored and davem330 committed tcp: fix a signed-integer-overflow bug in tcp_add_backlog() The type of sk_rcvbuf and sk_sndbuf in struct sock is int, and in tcp_add_backlog(), the variable limit is caculated by adding sk_rcvbuf, sk_sndbuf and 64 * 1024, it may exceed the max value of int and overflow. This patch reduces the limit budget by halving the sndbuf to solve this issue since ACK packets are much smaller than the payload. Fixes: c9c3321 ("tcp: add tcp_add_backlog()") Signed-off-by: Lu Wei &lt;luwei32@huawei.com&gt; Reviewed-by: Eric Dumazet &lt;edumazet@google.com&gt; Acked-by: Kuniyuki Iwashima &lt;kuniyu@amazon.com&gt; Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt; 1 parent 9c1eaa2 commit ec791d8 Copy full SHA for ec791d8 1 file changed + 3 - 1 Lines changed: 3 additions &amp; 1 deletion File tree Expand file tree Collapse file tree Open diff view settings Filter options net/ipv4 tcp_ipv4.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ net/ipv4/tcp_ipv4.c ‎ Copy file name to clipboard Expand all lines: net/ipv4/tcp_ipv4.c + 3 - 1 Lines changed: 3 additions &amp; 1 deletion Original file line number Diff line number Diff line change @@ -1874,11 +1874,13 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb, 1874 1874 __skb_push ( skb , hdrlen ); 1875 1875 1876 1876 no_coalesce : 1877 + limit = ( u32 ) READ_ONCE ( sk -&gt; sk_rcvbuf ) + ( u32 )( READ_ONCE ( sk -&gt; sk_sndbuf ) &gt;&gt; 1 ); 1878 + 1877 1879 /* Only socket owner can try to collapse/prune rx queues 1878 1880 * to reduce memory overhead, so add a little headroom here. 1879 1881 * Few sockets backlog are possibly concurrently non empty. 1880 1882 */ 1881 - limit = READ_ONCE ( sk -&gt; sk_rcvbuf ) + READ_ONCE ( sk -&gt; sk_sndbuf ) + 64 * 1024 ; 1883 + limit += 64 * 1024 ; 1882 1884 1883 1885 if ( unlikely ( sk_add_backlog ( sk , skb , limit ))) { 1884 1886 bh_unlock_sock ( sk ); 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. 