[PATCH net v7 6/9] ipv6: don't send redirects for decrypted skbs
From: Todd Freed
Date: Mon Nov 23 2026 - 20:07:39 EST
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@xxxxxxxxxx>
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@xxxxxxxxxxxxxxx
Signed-off-by: Todd Freed <toddfreed@xxxxxxxx>
---
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