Article View: linux.kernel.netdev
Article #22975Re: [PATCH net-next v1 0/6] net: avoid stack canaries in TCP/IPv4 fast paths
From: gang.yan
Date: Thu, 26 Nov 2026 08:48
Date: Thu, 26 Nov 2026 08:48
86 lines
12379 bytes
12379 bytes
November 24, 2026 at 9:06 PM, "Xuanqiang Luo" <xuanqiang.luo@linux.dev mailto:xuanqiang.luo@linux.dev?to=%22Xuanqiang%20Luo%22%20%3Cxuanqiang.luo%40linux.dev%3E > wrote: > > From: Xuanqiang Luo <luoxuanqiang@kylinos.cn> > > With CONFIG_STACKPROTECTOR_STRONG=y, a function that has a local array or > passes the address of one of its locals to another function needs a stack > canary. The canary is set up and checked on every call, also when the > local is only used on a path that almost never runs. > > This series removes the canary from functions of the TCP/IPv4 fast paths, > by returning results by value, by using storage that is not on the stack, > or by not calling a function that has nothing to do. > > Patch 1 returns the two mptcp_space() values in a structure, so that > __tcp_select_window() no longer needs a canary. > > Patch 2 changes ip_neigh_gw4() to take a pointer to the address, like > ip_neigh_gw6(), so that ip_finish_output2() no longer needs a canary. > > Patch 3 uses pskb_may_pull() in icmp_filter(), so that > raw_local_deliver() no longer needs a canary. > > Patch 4 turns skb_try_coalesce() into an inline wrapper over a function > returning its results by value, so that its callers no longer need a > canary because of it. > > Patch 5 returns the result of the TCP receive coalescing by value, so > that tcp_rcv_established() and tcp_data_queue() no longer need a canary. > > Patch 6 calls bpf_skops_write_hdr_opt(), which needs a canary, only if a > BPF program reserved room for TCP options. > > The bloat-o-meter numbers are from gcc 16.2 on x86_64. The functions > named in patches 1 to 5 also lose their canary with clang 23.1.6 on > x86_64, with and without ThinLTO, and on arm64. > Hi Xuanqiang, Thanks for this series. Besides the code size, do you have any runtime perf numbers (TCP_RR, cycles per packet...)? I think it may help the maintainers judge the real gain. Thanks Gang > Xuanqiang Luo (6): > tcp: avoid a stack canary in __tcp_select_window() > ipv4: avoid a stack canary in ip_finish_output2() > ipv4: raw: do not use skb_header_pointer() in icmp_filter() > net: avoid stack canaries in skb_try_coalesce() callers > tcp: avoid a stack canary in tcp_rcv_established() > tcp: do not call bpf_skops_write_hdr_opt() unless needed > > include/linux/filter.h | 2 +- > include/linux/skbuff.h | 35 ++++++++++- > include/net/mptcp.h | 13 ++++- > include/net/route.h | 16 +++--- > net/core/filter.c | 2 +- > net/core/skbuff.c | 50 ++++++++-------- > net/ipv4/raw.c | 25 ++++---- > net/ipv4/route.c | 15 +++-- > net/ipv4/tcp_input.c | 99 +++++++++++++++++--------------- > net/ipv4/tcp_output.c | 25 ++++---- > net/mptcp/subflow.c | 9 ++- > net/netfilter/nf_flow_table_ip.c | 4 +- > 12 files changed, 178 insertions(+), 117 deletions(-) > > base-commit: a4c450594f5d1dc0fc4daacfb95d40554d99dead > -- > 2.43.0 >
Technical Details
Message-ID:
<133c1ca98af6beb48c0db1e6bb539a2a76ccda49@linux.dev>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371966-linux-kernel-netdev=dewy.ruReferences:
<20261124130631.1886963-1-xuanqiang.luo@linux.dev>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371966-linux-kernel-netdev=dewy.ru From: gang.yan@linux.dev Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v1 0/6] net: avoid stack canaries in TCP/IPv4 fast paths Date: Thu, 26 Nov 2026 08:48:07 +0000 Organization: Usenet Network Message-ID: <133c1ca98af6beb48c0db1e6bb539a2a76ccda49@linux.dev> References: <20261124130631.1886963-1-xuanqiang.luo@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="419853"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:e05X6h7ytJslC9qsSJsuL+TVnqo= sha256:uwvxpnYN/98Lj/egc2cEEH4+jeiFaRBoh1vdj+GFguw= sha1:6OM+gtG4ED/+06NNGlW5IkcI6DM= sha256:P70T2b+aDJ9Nwd7reXlgqco5+joKBZCV4BuggqiDAtM= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id CBA97125EB6; Thu, 26 Nov 2026 11:48:33 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V49Mkv8cKxXj; Thu, 26 Nov 2026 11:48:29 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-371966-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 3FC82125EB0; Thu, 26 Nov 2026 11:48:20 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id C8F3628C0C; Thu, 26 Nov 2026 08:48:16 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795682896; b=xXdrVNageFC+epFPj4wPHvprap+3WO7i6dLl/QpcpcDkMPQpGb2+RRLs763kGldrXt88 4M44EpSDUJjavNqHtfawm3BBqWmbo9Hlc5Cao/2a4eQZsERNEV+bhgd5zu4QTSDTSJvw5 96uxgV+SKhiBsKaF13YiBjhE8QqlOYoElHnF8UzFRD2JqsHzkx8QkdGZR976FlOg6gIMV qxX0cYwcb/MWZTzY1IiAU4DUY3ThybLrR8mEo5B0DqSqtMSgTK7Iqf1gcaPdDjoFehoCA Yk02QUgnBuosTjtojiJQMnf9v9JaVDYtXILJOsEJhhzl+QAMJuaPDruLxrh5I+LE4sQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795682896; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Date:Content-Type: Content-Transfer-Encoding:From:Message-ID:TLS-Required:Subject:To:Cc: In-Reply-To:References; bh=eEqrglkqWiQv9ByDl8q6YHM+PPnMMtPyGy7NziGSOCE=; b=rbCC3qcuE1pI8U8BgzzPuFPzXj1zO5G+lWd+GikMkLBasvEB0zglIry4W3Wi7u9zThCD HXdHxvlmFFmGyRdtEatPU2xtUNxrreCkV4zjYnx+uGoEKYl72lVpw/qvoGCGyiqfIHNQc RVw54Eipn07Fs/hGN31vVjdxuDWKdyCCMXWeLtRZ4hCDta8gAYWfxyl4o4bjtZEUIrF5W QU+zWDGLNTIPISml6lCXOTETeRx7B0OsSNmVejhIT38ra03YosjAj8/CRk3fOuPsYxjkE Hm434Uo+6/csKoy4Zlt/s2iz/6M085/WyYTpieGzHtJyfZCQWLXlFNYxjK1rb7ZZOcQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CQp9twv8; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6919D606A321; Thu, 26 Nov 2026 08:48:16 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CQp9twv8 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.98 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795682890; b=Av4F4r9fWyX7IEavesJlfGiBxnH0UPxFhQN0oS+W2ssqBRFKAoadHFXn6rfFvZsXghmq 0+8XDSm8OufuZBy31fwHMD5RGUFtz1yh7CNVOHXNAgZ5jyrCCN1btAMVWpChQa+qNmb9H ZXa33HxZ5kZrJv2RSjE16TeatDpGXtfcHe1oxLELjndWEKDv6MJ3/ybLRWrPc1+GoWKJ/ v8jnqXSVzUpUpWbmhjso9xn26Ky3HSWj6w0svdgpL3bie3Et3L5HyLxmt+KL/zUsZ9BZk Y9DGB5/U+P2cpHXKIcECd88EjVdTOONxrWRIpt9kPeUuOKQQF8icqAz55cyIbmpPvCA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795682890; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:MIME-Version:Date:Content-Type: Content-Transfer-Encoding:From:Message-ID:TLS-Required:Subject:To:Cc: In-Reply-To:References; bh=eEqrglkqWiQv9ByDl8q6YHM+PPnMMtPyGy7NziGSOCE=; b=WRUXT219WdtcstpOLt0xkg31LYaaz/sEKRbIZ4m+diS7o/nsVt1kJu9ZhfyNIBO9d+qY u/4y0PzfBjH9H/hRKpR0OhetTDnLtVdhLaQsESIodLwVghVfpOCg9VLMmu0+WftYhhFbo ddx0NLJgqU8usn+pNrHoH+PGSI8QjCPihAb6uia+J6O8qivq5qW2w0+pKOCKZas7UwFd9 f7Z9SLpiAOGIEa+0uNGdk2gnYHwVCSePzR8rpfI820u30tCskIbiN6x9l0CbYvo9GHVYP sCVfAyYNYW5quueXmC5bN7yqmpm4qT5hKTDSmyEWqfDoyI2dqc6KZeqlpJjrKIE91ew== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=CQp9twv8; arc=none smtp.remote-ip=95.215.58.98 X-Received: from mta1.migadu.com (out-98.mta1.migadu.com [95.215.58.98]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9629C606A331 for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 08:48:09 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9629C606A331 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=WzPAXzKv5qNfueG+8GIA/dCl0/+muC6HE/6UOijGqYY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795682887; v=1; x=1796287687; b=CQp9twv8NqMVUqnxXo0xqr+FlGLWrxxigE8Bx5zCumkioE5w/pTtjE9TbWr/6mXpxOJH1iEu YYPkQ1i+3MVRmiUTTmCMSx0nH/9Gr5Rmn2IimpkQ1Biz/CvTOpzUW1POxv7Gv45jCGt09O7CsDt tpsaBl1LBQjfJTwuF/9IdVJ0= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 5446df3b68f9b5ae; Thu, 26 Nov 2026 08:48:07 +0000 X-Mizu-Trace-ID: 5446df3b68f9b5ae X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-TLS-Required: No X-Cc: "David S . Miller" <davem@davemloft.net>, "Eric Dumazet" <edumazet@kernel.org>, "Jakub Kicinski" <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, "Simon Horman" <horms@kernel.org>, "Alexei Starovoitov" <ast@kernel.org>, "Daniel Borkmann" <daniel@iogearbox.net>, "John Fastabend" <john.fastabend@gmail.com>, "Andrii Nakryiko" <andrii@kernel.org>, "Eduard Zingerman" <eddyz87@gmail.com>, "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, "Martin KaFai Lau" <martin.lau@linux.dev>, "Song Liu" <song@kernel.org>, "Yonghong Song" <yonghong.song@linux.dev>, "Jiri Olsa" <jolsa@kernel.org>, "Emil Tsalapatis" <emil@etsalapatis.com>, "Ihor Solodrai" <ihor.solodrai@linux.dev>, "Matthieu Baerts" <matttbe@kernel.org>, "Mat Martineau" <martineau@kernel.org>, "Geliang Tang" <geliang@kernel.org>, "David Ahern" <dsahern@kernel.org>, "Ido Schimmel" <idosch@nvidia.com>, "Stanislav Fomichev" <sdf@fomichev.me>, "Neal Cardwell" <ncardwell@google.com>, "Kuniyuki Iwashima" <kuniyu@google.com>, "Pablo Neira Ayuso" <pablo@netfilter.org>, "Florian Westphal" <fw@strlen.de>, "Phil Sutter" <phil@nwl.cc>, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, mptcp@lists.linux.dev, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, "Xuanqiang Luo" <luoxuanqiang@kylinos.cn> X-In-Reply-To: <20261124130631.1886963-1-xuanqiang.luo@linux.dev> X-Received-Bytes: 12121