mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v1 0/6] net: avoid stack canaries in TCP/IPv4 fast paths
@ 2026-11-24 13:06 Xuanqiang Luo
  2026-11-24 13:06 ` [PATCH net-next v1 1/6] tcp: avoid a stack canary in __tcp_select_window() Xuanqiang Luo
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Xuanqiang Luo @ 2026-11-24 13:06 UTC (permalink / raw)
  To: netdev
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Alexei Starovoitov, Daniel Borkmann,
	John Fastabend, Andrii Nakryiko, Eduard Zingerman,
	Kumar Kartikeya Dwivedi, Martin KaFai Lau, Song Liu,
	Yonghong Song, Jiri Olsa, Emil Tsalapatis, Ihor Solodrai,
	Matthieu Baerts, Mat Martineau, Geliang Tang, David Ahern,
	Ido Schimmel, Stanislav Fomichev, Neal Cardwell,
	Kuniyuki Iwashima, Pablo Neira Ayuso, Florian Westphal,
	Phil Sutter, bpf, linux-kernel, mptcp, netfilter-devel, coreteam,
	Xuanqiang Luo

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.

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-24 13:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 13:06 [PATCH net-next v1 0/6] net: avoid stack canaries in TCP/IPv4 fast paths Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 1/6] tcp: avoid a stack canary in __tcp_select_window() Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 2/6] ipv4: avoid a stack canary in ip_finish_output2() Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 3/6] ipv4: raw: do not use skb_header_pointer() in icmp_filter() Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 4/6] net: avoid stack canaries in skb_try_coalesce() callers Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 5/6] tcp: avoid a stack canary in tcp_rcv_established() Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 6/6] tcp: do not call bpf_skops_write_hdr_opt() unless needed Xuanqiang Luo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®