🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Daniel Borkmann Wed, 18 Nov 2026 12:58
Re: [PATCH net-next v1 07/15] bpf: don't redirect decrypted skbs from egress to ingress
#18515
Author: Daniel Borkmann
Date: Wed, 18 Nov 2026 12:58
54 lines
11873 bytes
On 11/11/26 1:55 AM, Todd Freed wrote:
> on transmit, skb->decrypted means the device must encrypt the packet.
> For example, a packet of a ktls or psp offload socket, or, with the tc
> psp action added later in this series, one which psp encap attached a
> tx association to.
> 
> on receive, skb->decrypted means the device decrypted the packet.
> 
> 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
> indicates the packet was decrypted by the device.
> 
> this is less of a problem with socket offloads, whose packets are by
> definition generated locally; more of a problem with socket-less psp,
> which can also apply to forwarded traffic.
> 
> in addition, the redirect drops the dst (skb_scrub_packet()), which for
> socket-less psp carries the tx association.
> 
> drop decrypted skbs which bpf redirects from egress to ingress. this
> matches the behavior of mirred, since the previous patch.
> 
> Signed-off-by: Todd Freed <toddfreed@meta.com>
> ---
>   net/core/filter.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index aca8160b26a1..a178a9dd3007 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2226,6 +2226,15 @@ 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;

This check should rather live in the bpf_redirect (and friends) helper e.g. after
we check for invalid params, etc, rather than here which feels off. Also, it would
probably make sense to refactor this condition into a small inline helper so you
don't have to open code it multiple times.

> +	}
> +
>   	if (dev_is_mac_header_xmit(dev))
>   		return __bpf_redirect_common(skb, dev, flags);
>   	else
Re: [PATCH net-next v1 07/15] bpf: don't redirect decrypted skbs from egress to ingress
#18681
Author: Daniel Borkmann
Date: Wed, 18 Nov 2026 18:26
49 lines
11821 bytes
On 11/18/26 6:46 PM, Todd Bert Freed wrote:
>>> +     /* 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;
>>
>> This check should rather live in the bpf_redirect (and friends) helper e.g. after
>> we check for invalid params, etc, rather than here which feels off. Also, it would
>> probably make sense to refactor this condition into a small inline helper so you
>> don't have to open code it multiple times.
> 
> Sounds good I will move this check into the two callers
> (bpf_clone_redirect() and
> skb_do_redirect()) under a helper.

But why under skb_do_redirect? I meant just here:

diff --git a/net/core/filter.c b/net/core/filter.c
index 532405988fd9..ba112111de22 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2471,6 +2471,8 @@ BPF_CALL_3(bpf_clone_redirect, struct sk_buff *, skb, u32, ifindex, u64, flags)
  
         if (unlikely(flags & (~(BPF_F_INGRESS) | BPF_F_REDIRECT_INTERNAL)))
                 return -EINVAL;
+       if (...cond...)
+               return -EOPNOTSUPP;
  
         /* BPF test infra's convert___skb_to_skb() can create type-less
          * GSO packets. gso_features_check() will detect this as a bad
@@ -2563,6 +2565,8 @@ BPF_CALL_2(bpf_redirect, u32, ifindex, u64, flags)
         if (unlikely(!bpf_net_ctx_get() ||
                      (flags & (~(BPF_F_INGRESS) | BPF_F_REDIRECT_INTERNAL))))
                 return TC_ACT_SHOT;
+       if (...cond...)
+               return TC_ACT_SHOT;
  
         ri = bpf_net_ctx_get_ri();
         ri->flags = flags;

> FYI this patch was moved to the net series "net: don't redirect
> decrypted skbs to
> ingress, psp time-wait validator", so you will see this applied to v3 there.
> 
> -Todd
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads