Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Todd Freed <toddfreed@meta.com>
To: <netdev@vger.kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"Björn Töpel" <bjorn@kernel.org>,
	"Boris Pismenny" <borisp@nvidia.com>,
	"Cosmin Ratiu" <cratiu@nvidia.com>,
	"Daniel Zahka" <daniel.zahka@gmail.com>,
	"David Ahern" <dsahern@kernel.org>,
	"Dragos Tatulea" <dtatulea@nvidia.com>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Ido Schimmel" <idosch@nvidia.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Leon Romanovsky" <leon@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-rdma@vger.kernel.org, "Mark Bloch" <mbloch@nvidia.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Raed Salem" <raeds@nvidia.com>,
	"Rahul Rameshbabu" <rrameshbabu@nvidia.com>,
	"Sabrina Dubroca" <sd@queasysnail.net>,
	"Saeed Mahameed" <saeedm@nvidia.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Simon Horman" <horms@kernel.org>,
	"Tariq Toukan" <tariqt@nvidia.com>,
	"Wei Wang" <weiwan@google.com>,
	"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH net v7 6/9] ipv6: don't send redirects for decrypted skbs
Date: Mon, 23 Nov 2026 17:05:58 -0800	[thread overview]
Message-ID: <20261124010601.3995693-7-toddfreed@meta.com> (raw)
In-Reply-To: <20261124010601.3995693-1-toddfreed@meta.com>

When ip6_forward() forwards a packet back out of the interface it came
in on, it sends an NDISC Redirect to the packet's source. The Redirected
Header option quotes as much of the invoking packet as fits in the
minimum IPv6 MTU. If the device had decrypted the packet (as indicated
by skb->decrypted), the redirect sends part of it back out onto the
network in cleartext.

The redirect is built by ndisc_send_redirect(), not icmp6_send(), so the
previous patch for ICMPv6 errors doesn't cover it. On IPv4 the redirect
goes through __icmp_send(), which the patch for ICMP errors covers.

Both PSP and kTLS RX device offload can get a decrypted skb forwarded:

 - mlx5 decrypts PSP packets whatever their destination address. A PSP
   packet encrypted with the server's key but addressed to another host
   on the link, and routed via the server, is decrypted and forwarded.
 - kTLS RX device offload keeps decrypting a connection's packets after
   its local address is removed. With TCP early demux disabled
   (net.ipv4.ip_early_demux=0), they are then forwarded. With early
   demux, ip6_forward() drops them, as early demux attached the socket.

Note that the forwarded packet itself is dropped by
sk_validate_xmit_skb() because of skb->decrypted.

Reproduced with mlx5 (ConnectX-7), with a client C, a server S and a
peer P on the same link. On S, forwarding is enabled on the interface
only:

  sysctl -w net.ipv6.conf.eth0.force_forwarding=1

PSP:

 - C routes P's address via S:
     ip -6 route add P/128 via S dev eth0
 - C connects to a TCP server on P, with PSP on its socket using S's
   key.
 - S's device decrypts the segments C sends, and ip6_forward() routes
   them back out of eth0 towards P. S sends the redirect.

kTLS:

kTLS RX device offload only decrypts the flows of local kTLS sockets, so
the packets have to belong to a connection to S that is no longer
delivered locally:

 - S has a second address S2 on the prefix. C opens a kTLS connection
   to S2, with kTLS RX device offload on S.
 - S disables TCP early demux (net.ipv4.ip_early_demux=0), then removes
   S2 while C keeps sending.
 - S's device keeps decrypting the connection's records, S forwards them
   back out of eth0, and sends C redirects quoting them in cleartext.

With this patch, no redirect is sent for the decrypted packets (in both
cases), and packets which weren't decrypted still get one.

Don't send redirects for decrypted skbs, as for skbs decapsulated from
IPsec.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117203137.804424-1-toddfreed%40meta.com
Fixes: 784abe24c903 ("net: Add decrypted field to skb")
Cc: stable@vger.kernel.org
Signed-off-by: Todd Freed <toddfreed@meta.com>
---
 net/ipv6/ip6_output.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 5b19683f08e0..d8ffe3837874 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -619,9 +619,12 @@ int ip6_forward(struct sk_buff *skb)
 	/* IPv6 specs say nothing about it, but it is clear that we cannot
 	   send redirects to source routed frames.
 	   We don't send redirects to frames decapsulated from IPsec.
+	   Nor to frames decrypted by the device: the redirect would quote
+	   them in cleartext.
 	 */
 	if (IP6CB(skb)->iif == dev->ifindex &&
-	    opt->srcrt == 0 && !skb_sec_path(skb)) {
+	    opt->srcrt == 0 && !skb_sec_path(skb) &&
+	    !skb_is_decrypted(skb)) {
 		struct in6_addr *target = NULL;
 		struct inet_peer *peer;
 		struct rt6_info *rt;
-- 
2.53.1-Meta


  parent reply	other threads:[~2026-11-24  1:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  1:05 [PATCH net v7 0/9] psp, tls: don't send offloaded contents in cleartext Todd Freed
2026-11-24  1:05 ` [PATCH net v7 1/9] net/mlx5e: ring the tx doorbell when an accel offload drops a packet Todd Freed
2026-11-24  1:05 ` [PATCH net v7 2/9] psp: don't encapsulate ipv6 packets with extension headers Todd Freed
2026-11-24  1:05 ` [PATCH net v7 3/9] net: don't fragment decrypted skbs Todd Freed
2026-11-24  1:05 ` [PATCH net v7 4/9] ipv4: icmp: don't quote decrypted payload in icmp errors Todd Freed
2026-11-24  1:05 ` [PATCH net v7 5/9] ipv6: icmpv6: don't quote decrypted payload in icmpv6 errors Todd Freed
2026-11-24  1:05 ` Todd Freed [this message]
2026-11-24  1:05 ` [PATCH net v7 7/9] selftests: drv-net: psp: test ipv6 tcp socket with extension headers Todd Freed
2026-11-24  1:06 ` [PATCH net v7 8/9] selftests: drv-net: psp: test that ipv4 psp packets aren't fragmented Todd Freed
2026-11-24  1:06 ` [PATCH net v7 9/9] net/mlx5e: psp: tso: replace only the length in checksum seed Todd Freed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124010601.3995693-7-toddfreed@meta.com \
    --to=toddfreed@meta.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=borisp@nvidia.com \
    --cc=cratiu@nvidia.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=raeds@nvidia.com \
    --cc=rrameshbabu@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=sd@queasysnail.net \
    --cc=shuah@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tariqt@nvidia.com \
    --cc=weiwan@google.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox