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 5/9] ipv6: icmpv6: don't quote decrypted payload in icmpv6 errors
Date: Mon, 23 Nov 2026 17:05:57 -0800 [thread overview]
Message-ID: <20261124010601.3995693-6-toddfreed@meta.com> (raw)
In-Reply-To: <20261124010601.3995693-1-toddfreed@meta.com>
An ICMPv6 error 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), then the ICMPv6 error is sending part of it back out
onto the network in cleartext.
As in the previous patch for ICMP, don't send an error about a received
decrypted skb at all: PSP also encrypts the L4 header, and telling it
apart from kTLS Rx device offload would rely on SKB_EXT_PSP not being
lost on the way. Linux receivers would drop an error whose quote stops
before the L4 header anyway (icmpv6_notify()). This covers ip6tables
REJECT and nft reject in the ip6 and inet families; the netdev and
bridge families are left to the nf patch, as for ICMP.
On Tx, skb->decrypted is also set. An error about a locally originated
skb (skb_iif is 0) is sent in full as before, if its route goes to a
local address (RTF_LOCAL), like RTCF_LOCAL in the previous patch.
An error about a received decrypted skb is dropped before the rate
limit, so that it doesn't use up the peer's and the global ICMPv6
credit. The check of a locally originated skb needs the route of the
error, which is looked up after the rate limit.
Like the other cases where icmp6_send() doesn't reply, log the drop with
net_dbg_ratelimited().
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261023234640.1459291-1-toddfreed%40meta.com
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Suggested-by: Björn Töpel <bjorn@kernel.org>
Fixes: 784abe24c903 ("net: Add decrypted field to skb")
Cc: stable@vger.kernel.org
Signed-off-by: Todd Freed <toddfreed@meta.com>
---
net/ipv6/icmp.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index d8203ebad882..9fe95a4774fc 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -778,6 +778,18 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
np = inet6_sk(sk);
+ /* Don't send parts of a decrypted skb onto the network, see
+ * __icmp_send(): no error about a received skb. Before the rate
+ * limit, so that such an error costs no credit. The check of a
+ * locally originated skb below needs the route of the error, which
+ * is looked up after the rate limit.
+ */
+ if (unlikely(skb_is_decrypted(skb) && skb->skb_iif)) {
+ net_dbg_ratelimited("%s: no reply to received decrypted packet [%pI6c > %pI6c]\n",
+ __func__, &hdr->saddr, &hdr->daddr);
+ goto out_unlock;
+ }
+
if (!icmpv6_xrlim_allow(sk, type, &fl6, apply_ratelimit))
goto out_unlock;
@@ -799,6 +811,17 @@ void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info,
if (IS_ERR(dst))
goto out_unlock;
+ /* An error about a locally originated decrypted skb is sent only if
+ * it is routed to a local address.
+ */
+ if (unlikely(skb_is_decrypted(skb)) &&
+ !(dst_rt6_info(dst)->rt6i_flags & RTF_LOCAL)) {
+ net_dbg_ratelimited("%s: no reply to locally originated decrypted packet [%pI6c > %pI6c]\n",
+ __func__, &hdr->saddr, &hdr->daddr);
+ dst_release(dst);
+ goto out_unlock;
+ }
+
ipc6.hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
msg.skb = skb;
--
2.53.1-Meta
next prev 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 ` Todd Freed [this message]
2026-11-24 1:05 ` [PATCH net v7 6/9] ipv6: don't send redirects for decrypted skbs Todd Freed
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-6-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