Netdev List
 help / color / mirror / Atom feed
* [PATCH nf] netfilter: reject: don't quote decrypted payload in icmp errors
@ 2026-11-23 23:18 Todd Freed
  0 siblings, 0 replies; only message in thread
From: Todd Freed @ 2026-11-23 23:18 UTC (permalink / raw)
  To: netfilter-devel
  Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Boris Pismenny, John Fastabend, Sabrina Dubroca, Daniel Zahka,
	Willem de Bruijn, Björn Töpel, coreteam, netdev,
	linux-kernel, stable

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-23 23:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 23:18 [PATCH nf] netfilter: reject: don't quote decrypted payload in icmp errors Todd Freed

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox