* [PATCH net 1/3] net/sched: act_mirred: don't send decrypted skbs from egress to ingress
2026-11-13 18:55 [PATCH net 0/3] net: don't redirect decrypted skbs to ingress, psp time-wait validator Todd Freed
@ 2026-11-13 18:55 ` Todd Freed
2026-11-13 18:55 ` [PATCH net 2/3] bpf: don't redirect " Todd Freed
2026-11-13 18:55 ` [PATCH net 3/3] psp: only give time-wait sockets of PSP connections a validator Todd Freed
2 siblings, 0 replies; 4+ messages in thread
From: Todd Freed @ 2026-11-13 18:55 UTC (permalink / raw)
To: netdev, toddfreed
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Daniel Zahka, Willem de Bruijn, Wei Wang,
Jamal Hadi Salim, Jiri Pirko, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, John Fastabend,
Stanislav Fomichev, Sabrina Dubroca, Boris Pismenny, bpf,
linux-kernel
On transmit, skb->decrypted means that the device must encrypt the
packet, e.g. a packet of a kTLS or PSP device offload socket.
On receive, skb->decrypted means that the device decrypted the packet,
and kTLS device offload trusts it as such (tls_device_decrypted()).
A packet which mirred redirects or mirrors from egress to ingress keeps
the bit. On ingress, it then claims to have been decrypted by the device,
although it was never encrypted, and its payload, which was to be
encrypted before leaving the host, could then be forwarded in cleartext.
Clearing skb->decrypted would not work, because that is what indicates
intent to encrypt the packet.
Don't send decrypted skbs from egress to ingress: a redirected one is
dropped, a mirrored one isn't copied.
Fixes: 414776621d10 ("net/tls: prevent skb_orphan() from leaking TLS plain text with offload")
Signed-off-by: Todd Freed <toddfreed@meta.com>
---
net/sched/act_mirred.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 1c98e4d81ebe..52c3eeab381a 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -285,6 +285,12 @@ static int tcf_mirred_to_dev(struct sk_buff *skb, struct tcf_mirred *m,
goto err_cant_do;
}
+ /* On transmit, decrypted asks the device to encrypt the packet. Sent
+ * to ingress, the packet would read as decrypted by the device.
+ */
+ if (unlikely(want_ingress && !at_ingress && skb_is_decrypted(skb)))
+ goto err_cant_do;
+
/* we could easily avoid the clone only if called by ingress and clsact;
* since we can't easily detect the clsact caller, skip clone only for
* ingress - that covers the TC S/W datapath.
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net 2/3] bpf: don't redirect decrypted skbs from egress to ingress
2026-11-13 18:55 [PATCH net 0/3] net: don't redirect decrypted skbs to ingress, psp time-wait validator Todd Freed
2026-11-13 18:55 ` [PATCH net 1/3] net/sched: act_mirred: don't send decrypted skbs from egress to ingress Todd Freed
@ 2026-11-13 18:55 ` Todd Freed
2026-11-13 18:55 ` [PATCH net 3/3] psp: only give time-wait sockets of PSP connections a validator Todd Freed
2 siblings, 0 replies; 4+ messages in thread
From: Todd Freed @ 2026-11-13 18:55 UTC (permalink / raw)
To: netdev, toddfreed
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Daniel Zahka, Willem de Bruijn, Wei Wang,
Jamal Hadi Salim, Jiri Pirko, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, John Fastabend,
Stanislav Fomichev, Sabrina Dubroca, Boris Pismenny, bpf,
linux-kernel
On transmit, skb->decrypted means that the device must encrypt the
packet, e.g. a packet of a kTLS or PSP device offload socket.
On receive, skb->decrypted means that the device decrypted the packet,
and kTLS device offload trusts it as such (tls_device_decrypted()).
bpf_redirect() and bpf_clone_redirect() with BPF_F_INGRESS send the
packet to a device's receive path with the bit still set, where it claims
to have been decrypted by the device, although it was never encrypted.
In addition, the redirect drops the metadata dst (skb_scrub_packet()),
which will hold the Tx association for socket-less PSP offload in the
net-next series "psp: introduce socket-less associations".
Drop decrypted skbs which bpf redirects from egress to ingress, as mirred
does since the previous patch.
Fixes: 414776621d10 ("net/tls: prevent skb_orphan() from leaking TLS plain text with offload")
Signed-off-by: Todd Freed <toddfreed@meta.com>
---
net/core/filter.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index 946b07a17fce..defbef3a9f75 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2226,6 +2226,16 @@ static int __bpf_redirect_common(struct sk_buff *skb, struct net_device *dev,
static int __bpf_redirect(struct sk_buff *skb, struct net_device *dev,
u32 flags)
{
+ /*
+ * On transmit, decrypted asks the device to encrypt the packet. Sent
+ * to ingress, the packet would read as decrypted by the device.
+ */
+ if (unlikely((flags & BPF_F_INGRESS) && !skb_at_tc_ingress(skb) &&
+ skb_is_decrypted(skb))) {
+ kfree_skb(skb);
+ return -EINVAL;
+ }
+
if (dev_is_mac_header_xmit(dev))
return __bpf_redirect_common(skb, dev, flags);
else
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net 3/3] psp: only give time-wait sockets of PSP connections a validator
2026-11-13 18:55 [PATCH net 0/3] net: don't redirect decrypted skbs to ingress, psp time-wait validator Todd Freed
2026-11-13 18:55 ` [PATCH net 1/3] net/sched: act_mirred: don't send decrypted skbs from egress to ingress Todd Freed
2026-11-13 18:55 ` [PATCH net 2/3] bpf: don't redirect " Todd Freed
@ 2026-11-13 18:55 ` Todd Freed
2 siblings, 0 replies; 4+ messages in thread
From: Todd Freed @ 2026-11-13 18:55 UTC (permalink / raw)
To: netdev, toddfreed
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Daniel Zahka, Willem de Bruijn, Wei Wang,
Jamal Hadi Salim, Jiri Pirko, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, Martin KaFai Lau, John Fastabend,
Stanislav Fomichev, Sabrina Dubroca, Boris Pismenny, bpf,
linux-kernel
psp_twsk_init() sets tw_validate_xmit_skb on TCP time-wait sockets.
Today, that becomes set whether or not the socket has PSP offload, which
is not needed but is harmless. psp_validate_xmit() passes such packets.
But a validator makes a socket look like it has an encryption offload of
its own. The tc psp action in the net-next series "psp: introduce
socket-less associations" relies on the presence of the validator to
determine whether the socket has an encryption offload.
Set the validator only when the socket has a PSP association with a Tx
key, as psp_sock_set_tx_key() does for full sockets.
Fixes: 6b46ca260e22 ("net: psp: add socket security association code")
Signed-off-by: Todd Freed <toddfreed@meta.com>
---
net/psp/psp_sock.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
index a6b1c42dd626..1df65505f1c6 100644
--- a/net/psp/psp_sock.c
+++ b/net/psp/psp_sock.c
@@ -314,10 +314,13 @@ void psp_twsk_init(struct inet_timewait_sock *tw, const struct sock *sk)
{
struct psp_assoc *pas = psp_sk_assoc(sk);
- if (pas)
+ if (pas) {
refcount_inc(&pas->refcnt);
+ /* like the full socket case in psp_sock_set_tx_key() */
+ if (pas->tx.spi)
+ tw->tw_validate_xmit_skb = psp_validate_xmit;
+ }
rcu_assign_pointer(tw->psp_assoc, pas);
- tw->tw_validate_xmit_skb = psp_validate_xmit;
}
void psp_twsk_assoc_free(struct inet_timewait_sock *tw)
--
2.53.1-Meta
^ permalink raw reply related [flat|nested] 4+ messages in thread