mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v3 0/3] ipv6: tie the dst cookie to the lookup that returned the dst
@ 2026-11-17  9:21 Ralf Lici
  2026-11-17  9:21 ` [PATCH net-next v3 1/3] ipv6: stamp the default route node with a fresh serial on link failure Ralf Lici
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ralf Lici @ 2026-11-17  9:21 UTC (permalink / raw)
  To: netdev
  Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Neal Cardwell,
	Kuniyuki Iwashima, Steffen Klassert, Herbert Xu,
	Florian Westphal, Sabrina Dubroca, Antonio Quartulli,
	linux-kernel

Hi,

This series implements a first part of the model proposed in [1] to
address the late cookie sampling race: a dst can be stored together with
a cookie read after a FIB change that its lookup did not see, and then
passes dst_check until the next change.

The case that made me post it as a series is xfrm. Adding a policy
restamps every fib6 node, so a socket whose lookup ran just before the
insertion keeps its plain dst and leaks plaintext although the policy
matches. I reproduced it for TCP connect and connected UDP, and the same
window lets a more specific blackhole route be bypassed for routes using
nexthop objects. The ovpn patch [2] hit the same pattern in
dst_cache_set_ip6.

The conversion is initially limited to tcp_v6_connect,
ip6_datagram_dst_update and ip6_sk_dst_lookup_flow. Other TCP TX cache
paths, including established-socket route refills, header rebuilds and
accepted-socket setup, still use late cookie sampling. This gives the
lookup-cookie API a small set of users and concrete fixes to review. If
the approach is accepted, I plan to follow up with a broader conversion
across the networking core and drivers.

Compared to [1], the fallback cookie is 0 instead of the pre-lookup
generation, so fib6_flush_trees is left alone, and nexthop-object dsts
are checked in ip6_dst_check instead of passing the generation down to
ip6_rt_pcpu_alloc. The other cache users (dst_cache, sctp, ipvs,
flowtable, sk_rx_dst, the xfrm bundle cookies) are not converted and
behave as before.

I tested it in a VM with lockdep, PROVE_RCU and DEBUG_ATOMIC_SLEEP,
using a debug-only delay after the lookup to hit the window: no
warnings, and the plaintext and blackhole bypass are gone in these test
cases.

I am targeting net-next to get feedback on the lookup-cookie API and its
incremental adoption before extending the conversion across the
remaining cache users. This series provides the writer-side
prerequisites and converts three socket-cache paths; it does not
complete the conversion. I am not requesting stable backports at this
stage. Backport scope and dependencies can be assessed separately once
the approach has been reviewed.

[1] https://lore.kernel.org/netdev/20260901122501.482920-1-ralf@mandelbit.com/
[2] https://lore.kernel.org/netdev/cover.1789639346.git.ralf@mandelbit.com/

Thanks,

Ralf Lici
Mandelbit Srl

---
Changes since v2 https://lore.kernel.org/all/cover.1794384146.git.ralf@mandelbit.com/
- Rebase onto current net-next, preserving the connected-only cache
  lookup introduced by f778e80b3daf ("ipv6: fix cached route reuse for
  control messages"). (Jakub)
- Move the serial update after rt6_multipath_rebalance in fib6_ifup and
  fib6_ifdown. (Sashiko)
- Add Fixes tags and improve wording. (Sashiko)
- Clarify that this is the groundwork for fixing the race and a partial
  conversion to the new API: other users will be covered in a follow-up
  series.

Changes since v1 https://lore.kernel.org/netdev/cover.1793806941.git.ralf@mandelbit.com/
- Fix kdoc return statements in patch 2/3. (NIPA)

Ralf Lici (3):
  ipv6: stamp the default route node with a fresh serial on link failure
  ipv6: add ip6_dst_lookup_flow_cookie
  ipv6: use lookup cookies in selected socket dst cache paths

 include/net/ip6_route.h | 18 +++++++++----
 include/net/ipv6.h      | 13 ++++++++++
 net/ipv6/datagram.c     |  6 +++--
 net/ipv6/ip6_output.c   | 57 ++++++++++++++++++++++++++++++++++++++---
 net/ipv6/route.c        | 30 +++++++++++-----------
 net/ipv6/tcp_ipv6.c     |  5 ++--
 6 files changed, 101 insertions(+), 28 deletions(-)


base-commit: 6ff4c5942a301675eb12e5b49d53a81e604624a1
-- 
2.56.0


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

end of thread, other threads:[~2026-11-17  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17  9:21 [PATCH net-next v3 0/3] ipv6: tie the dst cookie to the lookup that returned the dst Ralf Lici
2026-11-17  9:21 ` [PATCH net-next v3 1/3] ipv6: stamp the default route node with a fresh serial on link failure Ralf Lici
2026-11-17  9:21 ` [PATCH net-next v3 2/3] ipv6: add ip6_dst_lookup_flow_cookie Ralf Lici
2026-11-17  9:21 ` [PATCH net-next v3 3/3] ipv6: use lookup cookies in selected socket dst cache paths Ralf Lici

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®