mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Todd Bert Freed <toddfreed@meta.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"Björn Töpel" <bjorn@kernel.org>,
	bpf@vger.kernel.org, "Daniel Zahka" <daniel.zahka@gmail.com>,
	"Donald Hunter" <donald.hunter@gmail.com>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Jiri Pirko" <jiri@resnulli.us>,
	"John Fastabend" <john.fastabend@gmail.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Saeed Mahameed" <saeedm@nvidia.com>,
	"Simon Horman" <horms@kernel.org>,
	"Tariq Toukan" <tariqt@nvidia.com>,
	"Wei Wang" <weiwan@google.com>,
	"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>
Subject: Re: [PATCH net-next v1 07/15] bpf: don't redirect decrypted skbs from egress to ingress
Date: Wed, 18 Nov 2026 19:26:53 +0100	[thread overview]
Message-ID: <4d271539-b2f5-4fb9-a4dd-32becd02ce5e@iogearbox.net> (raw)
In-Reply-To: <CADh2yMxffQ3cywT3aNg3SkVfog5CFnUSp34F1esyun-xUBVa9g@mail.gmail.com>

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


  reply	other threads:[~2026-11-18 18:27 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  0:55 [PATCH net-next v1 00/15] psp: introduce socket-less associations Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 01/15] psp: get netns from net_device instead of sock Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 02/15] psp: take the psp nexthdr from the packet on encap Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-17 22:17     ` Todd Bert Freed
2026-11-11  0:55 ` [PATCH net-next v1 03/15] psp: declare psp_assoc_set_tx() in psp.h Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 04/15] psp: add support for socket-less psp associations Todd Freed
2026-11-11 16:49   ` Daniel Zahka
2026-11-11 18:23     ` Todd Bert Freed
2026-11-11 19:01       ` Daniel Zahka
2026-11-11 21:49         ` Todd Bert Freed
2026-11-12  0:51     ` Todd Bert Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-17 22:19     ` Todd Bert Freed
2026-11-11  0:55 ` [PATCH net-next v1 05/15] net: add METADATA_PSP dst to carry a psp association on an skb Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-17 22:23     ` Todd Bert Freed
2026-11-11  0:55 ` [PATCH net-next v1 06/15] net/sched: act_mirred: don't send decrypted skbs from egress to ingress Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 07/15] bpf: don't redirect " Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-17 22:29     ` Todd Bert Freed
2026-11-18 12:58   ` Daniel Borkmann
2026-11-18 17:46     ` Todd Bert Freed
2026-11-18 18:26       ` Daniel Borkmann [this message]
2026-11-18 19:15         ` Todd Bert Freed
2026-11-11  0:55 ` [PATCH net-next v1 08/15] psp: only give time-wait sockets of psp connections a validator Todd Freed
2026-11-11 11:37   ` Daniel Zahka
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-17 22:04     ` Todd Bert Freed
2026-11-11  0:55 ` [PATCH net-next v1 09/15] net/sched: add act_psp for psp transport mode Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-17 22:46     ` Todd Bert Freed
2026-11-11  0:55 ` [PATCH net-next v1 10/15] net/sched: flower: add psp_spi, psp_ver, and psp_dev matches Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-17 22:54     ` Todd Bert Freed
2026-11-11  0:55 ` [PATCH net-next v1 11/15] selftests: drv-net: psp: test socket-less associations and the tc psp action Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 12/15] selftests: drv-net: psp: test that software encap on ingress drops Todd Freed
2026-11-11  0:55 ` [PATCH net-next v1 13/15] selftests: tc-testing: run dependsOn probes outside the test namespace Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 14/15] selftests: tc-testing: add tests for the psp action Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11  0:55 ` [PATCH net-next v1 15/15] Documentation: networking: psp: document socket-less associations Todd Freed
2026-11-15  3:18   ` netdev-bot+sashiko
2026-11-11 17:01 ` [PATCH net-next v1 00/15] psp: introduce " Daniel Zahka
2026-11-12 19:35   ` Todd Bert Freed
2026-11-13 15:45 ` Jamal Hadi Salim
2026-11-13 16:21   ` Jamal Hadi Salim
2026-11-13 19:08     ` Todd Bert 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=4d271539-b2f5-4fb9-a4dd-32becd02ce5e@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=toddfreed@meta.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

all inboxes | Powered by JetHome®