Netdev List
 help / color / mirror / Atom feed
From: Todd Freed <toddfreed@meta.com>
To: <netfilter-devel@vger.kernel.org>
Cc: "Pablo Neira Ayuso" <pablo@netfilter.org>,
	"Florian Westphal" <fw@strlen.de>, "Phil Sutter" <phil@nwl.cc>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Boris Pismenny" <borisp@nvidia.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Sabrina Dubroca" <sd@queasysnail.net>,
	"Daniel Zahka" <daniel.zahka@gmail.com>,
	"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
	"Björn Töpel" <bjorn@kernel.org>,
	coreteam@netfilter.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH nf] netfilter: reject: don't quote decrypted payload in icmp errors
Date: Mon, 23 Nov 2026 15:18:35 -0800	[thread overview]
Message-ID: <20261123231835.2356740-1-toddfreed@meta.com> (raw)

On receive, skb->decrypted means that the device decrypted the skb
(kTLS device offload, PSP). For a decrypted skb, any part of the packet
which had been encrypted should not be sent back onto the network in
cleartext.

These patches in the net series,

https://lore.kernel.org/netdev/20261117203137.804424-1-toddfreed@meta.com

 ipv4: icmp: don't quote decrypted payload in icmp errors
 ipv6: icmpv6: don't quote decrypted payload in icmpv6 errors

make the IP stack not send any ICMP error about a received decrypted
skb.

The reject expression in netdev and bridge chains builds its own ICMP
errors, without icmp_send() and icmpv6_send().
nf_reject_skb_v4_unreach() and nf_reject_skb_v6_unreach() quote up to
536 and 1220 bytes of the packet. Apply the rule to these paths too.
These only get received skbs, as the netdev and bridge reject
expressions are limited to the ingress, prerouting and input hooks, so
unlike icmp_send() no locally originated case needs to be kept.

The reject rule still drops the packet, but without a reply, as it
already does in other cases (non-first fragments, ICMP errors, bad
checksums).

nf_send_unreach() and nf_send_unreach6() use icmp_send() and
icmpv6_send(), which are covered by the net series.

Testing:

Reproduced with mlx5 (ConnectX-7) on net/main, with a reject rule in a
netdev ingress chain on the receiving host matching an established
connection. With kTLS RX device offload, the ICMP and ICMPv6
unreachables quoted the decrypted TLS payload in cleartext. With PSP
sockets, the ICMPv6 unreachables quoted the decrypted TCP header and
payload. With this patch, no ICMP error is sent for the decrypted
packets.

Fixes: 784abe24c903 ("net: Add decrypted field to skb")
Cc: stable@vger.kernel.org
Signed-off-by: Todd Freed <toddfreed@meta.com>
---

Notes:
    This supersedes the 2-patch nf-next series "netfilter: don't send
    decrypted skbs in clear text":
    https://lore.kernel.org/netfilter-devel/20261111003111.3826942-1-toddfreed@meta.com
    
     - Patch 2/2, "netfilter: reject: don't reply to decrypted skbs",
       reproduces on net/main, so it is resent here to nf as a fix, reduced
       to the ICMP errors.
     - Patch 1/2, "netfilter: bridge: don't refragment decrypted skbs", is
       dropped. I could not reproduce it on mlx5, neither on net/main nor
       with the socket-less PSP series: the device doesn't decrypt PSP in IP
       fragments.

 net/ipv4/netfilter/nf_reject_ipv4.c | 7 +++++++
 net/ipv6/netfilter/nf_reject_ipv6.c | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c b/net/ipv4/netfilter/nf_reject_ipv4.c
index 7cb33af671e2..4d89ec6a4a91 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -118,6 +118,13 @@ struct sk_buff *nf_reject_skb_v4_unreach(struct net *net,
 	if (!nf_reject_iphdr_validate(oldskb))
 		return NULL;
 
+	/* Don't send the decrypted part of an skb onto the network: the
+	 * device decrypted a received skb, and this reply quotes it. Only
+	 * received skbs get here (bridge, netdev ingress).
+	 */
+	if (unlikely(skb_is_decrypted(oldskb)))
+		return NULL;
+
 	/* IP header checks: fragment. */
 	if (ip_hdr(oldskb)->frag_off & htons(IP_OFFSET))
 		return NULL;
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c b/net/ipv6/netfilter/nf_reject_ipv6.c
index 5e08d8529cc8..fc30569b1f4d 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -144,6 +144,13 @@ struct sk_buff *nf_reject_skb_v6_unreach(struct net *net,
 	if (!nf_reject_ip6hdr_validate(oldskb))
 		return NULL;
 
+	/* Don't send the decrypted part of an skb onto the network: the
+	 * device decrypted a received skb, and this reply quotes it. Only
+	 * received skbs get here (bridge, netdev ingress).
+	 */
+	if (unlikely(skb_is_decrypted(oldskb)))
+		return NULL;
+
 	/* Don't reply to ICMPV6_DEST_UNREACH with ICMPV6_DEST_UNREACH */
 	if (nf_skb_is_icmp6_unreach(oldskb))
 		return NULL;

base-commit: 734bef548a96e8774d6eef5dfa2026c6edc4e80b
-- 
2.53.1-Meta


                 reply	other threads:[~2026-11-23 23:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261123231835.2356740-1-toddfreed@meta.com \
    --to=toddfreed@meta.com \
    --cc=bjorn@kernel.org \
    --cc=borisp@nvidia.com \
    --cc=coreteam@netfilter.org \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=sd@queasysnail.net \
    --cc=stable@vger.kernel.org \
    --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