🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19062

Re: [PATCH net-next v3 3/3] ipv6: use lookup cookies in selected socket dst cache paths

#19062
From: netdev-bot+sashiko
Date: Thu, 19 Nov 2026 09:22
130 lines
12684 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch fixes the IPsec-bypass race (late cookie sampling) in
  only three paths: tcp_v6_connect(), ip6_datagram_dst_update() and…
- [Low] This patch carries a Fixes: tag and is the one stable selection
  will pick.

--

ipv6: use lookup cookies in selected socket dst cache paths

This commit changes tcp_v6_connect(), ip6_datagram_dst_update() and
ip6_sk_dst_lookup_flow(). They now store the cookie returned by
ip6_dst_lookup_flow_cookie() instead of sampling it after the lookup.
The commit also adds ip6_dst_store_cookie() and keeps ip6_dst_store() as
a wrapper for callers that are not converted yet.

> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")

[Severity: Low]
This patch depends on the earlier commit "ipv6: add
ip6_dst_lookup_flow_cookie". That commit does three things:

- adds ip6_dst_lookup_flow_cookie()
- changes ip6_dst_check() so that a dst with rt->sernum must match the
  supplied cookie
- moves the fib6_update_sernum() calls in fib6_ifup()/fib6_ifdown() to
  after rt6_multipath_rebalance()

The prerequisite has no Fixes: tag and no stable note. This commit does
not mention the dependency either.

If stable selection picks only this commit because of its Fixes: tag, it
will not build, since ip6_dst_lookup_flow_cookie() is undefined. Could the
prerequisite be tagged too, or the dependency be noted here, so both get
backported together?

> diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
> index 95f936be32c6c..2684f6069a5e1 100644
> --- a/include/net/ip6_route.h
> +++ b/include/net/ip6_route.h

[ ... ]

> @@ -266,8 +266,16 @@ static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
>  #endif
>  }
>  
> +static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
> +				 bool daddr_set,
> +				 bool saddr_set)
> +{
> +	ip6_dst_store_cookie(sk, dst, rt6_get_cookie(dst_rt6_info(dst)),
> +			     daddr_set, saddr_set);
> +}

[Severity: High]
This wrapper still samples the cookie after the lookup. Three other
writers of np->dst_cookie on TCPv6 sockets still go through it:

net/ipv6/inet6_connection_sock.c:inet6_csk_route_socket() {
    ...
	dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p);

	if (!IS_ERR(dst))
		ip6_dst_store(sk, dst, false, false);
    ...
}

net/ipv6/af_inet6.c:inet6_sk_rebuild_header() {
    ...
	dst = ip6_dst_lookup_flow(sock_net(sk), sk, fl6, final_p);
    ...
	ip6_dst_store(sk, dst, false, false);
    ...
}

net/ipv6/tcp_ipv6.c:tcp_v6_syn_recv_sock() {
    ...
	memcpy(newnp, np, sizeof(struct ipv6_pinfo));

	ip6_dst_store(newsk, dst, false, false);
    ...
}

Can the same xfrm policy bypass still happen through these paths?

xfrm_policy_insert() links the policy and then calls
rt_genid_bump_ipv6(). Suppose an insertion lands between
ip6_dst_lookup_flow() returning a plain route and the rt6_get_cookie()
call inside ip6_dst_store(). The plain dst is then cached with the new
serial, and ip6_dst_check() keeps accepting it.

These paths run much more often than tcp_v6_connect():

- After connect(), every refill for an established socket goes through
  inet6_csk_xmit()->inet6_csk_route_socket() whenever __sk_dst_check()
  fails. That includes the invalidation caused by the policy insertion
  itself.
- A remote ICMPv6 Packet Too Big can force refills via
  tcp_v6_mtu_reduced()->inet6_csk_update_pmtu()->inet6_csk_route_socket().
- For accepted sockets, tcp_v6_syn_recv_sock() reads the cookie only
  after inet6_csk_route_req(), tcp_create_openreq_child() and the
  ipv6_pinfo memcpy. That window is wider than the one in connect().

The commit message says this is a partial conversion. With the Fixes:
tag, though, stable trees would get a fix that leaves established active
sockets and all accepted sockets exposed. The new kernel-doc for
ip6_dst_lookup_flow_cookie() also says "A caller caching the dst should
use this cookie when validating it with dst_check". These callers don't
do that.

Would it make sense to convert inet6_csk_route_socket(),
inet6_sk_rebuild_header() and tcp_v6_syn_recv_sock() in this patch as
well?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794906743.git.ralf%40mandelbit.com
Technical Details
Message-ID: <179508017589.3136.2311893930440004501@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366884-linux-kernel-netdev=dewy.ru
References: <60907e12930f38ba6c45c4ccfdca7abee068b765.1794906743.git.ralf@mandelbit.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366884-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 3/3] ipv6: use lookup cookies in selected
 socket dst cache paths
Date: Thu, 19 Nov 2026 09:22:55 +0000
Organization: Usenet Network
Message-ID: <179508017589.3136.2311893930440004501@kernel.org>
References: <60907e12930f38ba6c45c4ccfdca7abee068b765.1794906743.git.ralf@mandelbit.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2837726"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:QzF91lbGCxFCWiSP70BlzfHejq8= sha256:1sIMHvczoINaIAAM6lWimITZyuQRbX7PwJRimbOZHL8=
	sha1:3f8KsPbzoyv8CrJ3wka9miHxwxU= sha256:0665nzT9KHgkk7neNzVk/ljxxZnKVe6GW/G1bnDQpV8=
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 135B711557A; Thu, 19 Nov 2026 12:23:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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 (2048-bit key)
	header.d=kernel.org
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 RouddIq6HsLC;
	Thu, 19 Nov 2026 12:23:19 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366884-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 0CB52115580; Thu, 19 Nov 2026 12:23:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 189AE3066A5; Thu, 19 Nov 2026 09:23:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1795080178;
	b=C4cCWwrEZsfqb49TP1aiykrCmNx2u69XLtRZhV0CWgroZpJXrQsy//DqN+XyOtBsvcCg
	 ML0HEPLWjWYlQQslKF6uux7qbXkQbdiN+Jctd6eVC5DNX2nkE2dYAmoUFbWfaLzqrjrBv
	 446gS3mY+Ysihu40ONYWWKKp3O37zWa6ZUJCr8y5u+n6PbY6e/vTHpD7M+q+WCJvEle4v
	 lH88S9xUH9pv/SmDiuhWA6S/sypAaCm/sYjs/nT5C8PRXOKqAoafN8QxjB795ray3PoiN
	 b0dj6acIko3TX3rR+qLilkbIMtxvuHlvSiRIt97AAT8aIVhltmpA9NdM7tCuH/uT/xA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795080178;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=BQ2lnBFbJ23uOP8A1QEFwnqNG7eY2eGB8Q6tQ0RjBRI=;
	b=cDvubk24STNIWc2xxAAtiKzeHyKYCg9qbLtAa0aowdYWSBPhh3+iabVGVAC3Mi+NIQ2T
	 xrfM6zDTYwg09nGckUEEhcOZOfs8L1g6p6fYuzrGRKcoeWhPqCFuD9zEr81CJKZz8L5Ww
	 r6OiER1yk3mqiWGDtRwIMwi751qLOCUONFi2t3ttak+4+RCfREMoyINUcMU/+h0dGM6JL
	 I/0DO7Afn70brTwYZErxjb2mtPl8Joem+ZLmpeZ6Oooeu+Dxt/zmpQxA8kE5Wk96J8keJ
	 iKunMy8jvnOtMZmw2MQoShlQHSWbp8J6rV7ZTvyUg9OWxNwIEKPeWZBFutAznOd/HtA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Vhg1ojQ2;
	arc=fail 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 84D7F606A334;
	Thu, 19 Nov 2026 09:22:58 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Vhg1ojQ2
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795080177;
	b=UKyvfU/peNdGCxp5AozAVPO9CgtmmDQUxnHsuhQDjlqz42RI8PvuQpFZw+PzxN0bwuy7
	 zch+mLow3mnEBeMq0LFbDzGYov/NtE7Z39H4JUOijotLsyKkMNzcEIOxtmBz+Z2/CntKM
	 T3B+tvdjbKAyUvLDDEItz1YDkS/6LxNj4lDAJw80t7GN6uvwMBSlhv80pCBMZ2C4zPCJ7
	 KsT3UvOrTIJ1hs5xh8ANxb+NsdZfShDFo+dtNN467cSJoK22bqdzyPUgkUAbk9Tk5Leo6
	 y/60NKKlS1QJPGn4ExOIIE6m+pBg4HibbpqZH+fMRuqMUueBKGAQW6Jp1qx07KoqO1A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795080177;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=BQ2lnBFbJ23uOP8A1QEFwnqNG7eY2eGB8Q6tQ0RjBRI=;
	b=mdHeXHWYWuALOIoUBdoIMX5cu8+F0kPHL8HkmgvgirSAF6JeVaEx81F1BT6yn88ZIipX
	 AVyi+O2lwtE4+m05zd3rXdN7NXBngG2QcY1FlN89nLkl6mYHVEmbOPrcDqhr37DT9MLly
	 AUqSa5qYrqoOg9gRcnXe2zteYBJqwhqEHHBm4RCa/pgz3anYvg3EaydDO1HjanWvwvrtR
	 16z0YHDuKT9SI7wP6CteKrHi08ytaA7/FjsH2bRCTIaGmzOXEtRpi10yObVY4ehQ4zsZH
	 2RTQBS1WkhjWTfNbFKbfrNJyJD2iusdEuwSBdUQDBEOy/u4TS7zANkX6xkbGo09jvEQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Vhg1ojQ2;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A613C60A261C;
	Thu, 19 Nov 2026 09:22:57 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51BE11F000C9;
	Thu, 19 Nov 2026 09:22:56 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795080177;
	bh=BQ2lnBFbJ23uOP8A1QEFwnqNG7eY2eGB8Q6tQ0RjBRI=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Vhg1ojQ2Rc6va153o1ENe21se5QAcg08aI+bwjpY3OhxrjAF23QtUfTW5YJzyWi8h
	 MNw3dK+aaFz4yhCNsw+m7ikn1gh5MTzSZtIUTjf5OgNtvtguHFTCH6yg8zvgSqiD/R
	 UXLqlGIOxVRan+9gRE9VvicNq5ivBC8r5bbDNjbdh3q6RWpz+5UPzsmSV8dXB9nLhk
	 iFvTLJBXNB1+JOGbjTZUmuihYoYDX8kmJFR/PeADNVCiNLVgZ6defra61TEJ/w9S3g
	 Pw5dRuOt6L8gesRUtoQ1WPuGTuNCPnpM5ayJg2pvarNrPvseG/xQe9PwcV+MibDwlu
	 vItMk9N4vxLpA==
X-Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 horms@kernel.org, ncardwell@google.com, kuniyu@google.com,
 steffen.klassert@secunet.com, herbert@gondor.apana.org.au, fw@strlen.de,
 sd@queasysnail.net, antonio@mandelbit.com, linux-kernel@vger.kernel.org
X-In-Reply-To: <60907e12930f38ba6c45c4ccfdca7abee068b765.1794906743.git.ralf@mandelbit.com>
X-sashiko-severity: High
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