Article View: linux.kernel.netdev
Article #18515Re: [PATCH net-next v1 07/15] bpf: don't redirect decrypted skbs from egress to ingress
From: Daniel Borkmann
Date: Wed, 18 Nov 2026 12:58
Date: Wed, 18 Nov 2026 12:58
54 lines
11873 bytes
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
Technical Details
Message-ID:
<ea8a18e0-12cc-48e0-903e-325a8ece5a0f@iogearbox.net>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366123-linux-kernel-netdev=dewy.ruReferences:
<20261111005533.6436-1-toddfreed@meta.com> <20261111005533.6436-8-toddfreed@meta.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer05.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366123-linux-kernel-netdev=dewy.ru From: daniel@iogearbox.net (Daniel Borkmann) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v1 07/15] bpf: don't redirect decrypted skbs from egress to ingress Date: Wed, 18 Nov 2026 13:58:26 +0100 Organization: Usenet Network Message-ID: <ea8a18e0-12cc-48e0-903e-325a8ece5a0f@iogearbox.net> References: <20261111005533.6436-1-toddfreed@meta.com> <20261111005533.6436-8-toddfreed@meta.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="2597975"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:0if3EsmMYA3bPTrHMx4qdmgrYfM= sha256:XqrOazw1RPc1nxI556LvGZ4l2MJXtmzgsAzKCAettks= sha1:fnVRGyzCRnVy+i18jJDvSoLRxjc= sha256:XU144cokRb8xUkP6hAEZR+JbGcok8WgpPJ6nbf/MLk0= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 7AA0411529E; Wed, 18 Nov 2026 15:59:22 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=iogearbox.net X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id udHM3p806AK3; Wed, 18 Nov 2026 15:59:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-366123-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=reject dis=none) header.from=iogearbox.net X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 2321011529A; Wed, 18 Nov 2026 15:59:10 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 86F4946B59; Wed, 18 Nov 2026 12:58:59 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795006735; b=KqVeP+II2QaBWUIRu2gD/47tnTzf1BH/ttYbVjDrDTquRzoPSGS+XNTuAzt444JvCPVP eTfEqspjnkcKpuTs7djHkTYM6nmNGzwzXK43kB/DDmBAWmIvbzrptd+QXM/gsx8hvPkZM DiagHEs/fW5NsQEOb3eiL2Iqlpu0MjOImeM6fc2HWoR0gNEqQJOitMt/EJxMIl2+8jWa0 /BVY35Xm+Rbd7gric4N6CdPHuWKa3fyMyGYfbNeh0drzZgHFR7DpGNNxam0W7Dgz0HcRm yLCnE8v91DbSlxI6viKUDWs+DjlwnO8E1aqaHQ3mYKPbKOeStvSTsJyOZaZcBJke11g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795006735; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Received: Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-Virus-Scanned; bh=zmvoEpqpabGUDsHZXTw1VbdurVjwfR2E9sHZpTo3HYM=; b=3Cb9TlBAIWrMS5L+AMmg5l53ZLVI7Y4VS37eMY861nkOZt50B6KTHqbW/mEErkaN+DE2 I3QpC/a7Up92/52OCeLQEpaKXZVWV7FTE0gVQbnvgyXYEVmLhvoSz1J9IZFcSw+9TdTlk gvnV1b0ZBQHUQbss0ZE8RdFFv19H/j+bIWTE+mgEARrCgYSiWZj3dMFITqHWeNDcv6NAE LxFmao5vYwZb1AEZ2U3ZQsQlbrHQUYdui3qHq5+lv4ZXQt5UT+aawlGBtgPyporE9oTxL RRf/kgQS3cQmwpalE5/avtjbnzfbXg5rjPQimr8l+Po8Rlh0bJj1T1kezNzWGSA2tPQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=iogearbox.net header.i=@iogearbox.net header.a=rsa-sha256 header.s=default2302 header.b=IMyNwftp; dmarc=pass header.from=iogearbox.net; spf=pass smtp.mailfrom=iogearbox.net; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0126A60A260C; Wed, 18 Nov 2026 12:58:55 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iogearbox.net header.i=@iogearbox.net header.a=rsa-sha256 header.s=default2302 header.b=IMyNwftp X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=213.133.104.62 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795006729; b=Co9dTaOVCfqnULECVAvXSgk1DvCydVj/gT33bNQKNclW7utGkg8LZQaT9Vs9wN3Uu6yQ QjTS+EGs7XE8E8UkHcFqJj3lx04GfvTEAXtHmPt9MSOBFSp1z0cfvYpJMmLcb7sUBM8wR bKvO1rFtnhFYVe/xIc3YWAxP2S6N4WaWK3JHwgzFH6PJgrn/uI+IkGRcJLRrXuLsEaAQ2 IKvtL1T8JaY7NVYvDs/YwpzkUCiH5W/eASYLgrVVs4meEHITMpwN2Fg/HZpn3ApDTa+xh CoF01U4IVUiDQJcqsa0/vlSYRkg8qogFl9EdmyQR5A676ydEDxxOy6cxpEOU9FpYDCA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795006729; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding: X-Virus-Scanned; bh=zmvoEpqpabGUDsHZXTw1VbdurVjwfR2E9sHZpTo3HYM=; b=WKmPttozYCo1Wp7TV45T+E+PUvBptnxDcEEZphLzFlEk94mVYS3OWdUfm0v3jZ3KGxqq XG+t5FUXYHAkMtALlo0fBpOiPSNgLAFPCcznsUsSaJjEsFhu4XJvDDHXHtqQzGuRs0pfz MRopzYTXSeLgNCzFXNAYgccrHtwkvvkAFc8GAfWqlj3+eFFGT6z3eLQ6bzxlMZEg6EYI+ FQE7X8wHKneW3Xi+cmgxrR6ckZyYypWxQAjNkGYieUvVx8u6x0okegxVP6wVRYF0gLGCB 1ylGJ/4IimIWkIF5gxurNrEhQ41yzzpzfANicabmJnfAWN3QRv9oep5JQFWkM/LUcNw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=iogearbox.net; spf=pass smtp.mailfrom=iogearbox.net; dkim=pass header.d=iogearbox.net header.i=@iogearbox.net header.a=rsa-sha256 header.s=default2302 header.b=IMyNwftp; arc=none smtp.remote-ip=213.133.104.62 X-Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2101F606A31C; Wed, 18 Nov 2026 12:58:47 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2101F606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iogearbox.net X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iogearbox.net X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=iogearbox.net; s=default2302; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=zmvoEpqpabGUDsHZXTw1VbdurVjwfR2E9sHZpTo3HYM=; b=IMyNwftpJQEBaOtzIEomo/t7jA vkVKeXPQoA7pYiC+2twrNnhLQd0YAs50KQTXzTqZiThLSUfCT1V4bIO7I5nMCrTp/q3y126Ybxpxc ZMTMSnsF6ALNVgk7NgX+3RbTNP3WiPz2npr/YzHgA0+l3ke+Z609hcLwKu4Iy6BGCSTtfB/AFrSI5 hIh/fW5DPOyJSsCCTwsSeNRzviEHBJ8FA6IHpNfLZKc4EZ+EkVuYyRoYck4Yse4V6JB0cLquUNXpE UZduZCDYsp+NWVFgNswnfYTezTQ6PBxc45a+Ic7sGpfxKmSVwd7Hwh/XuxD3cn3RHh5IxdTd8AdxK TchBa8SQ==; X-Received: from sslproxy01.your-server.de ([78.46.139.224]) by www62.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from <daniel@iogearbox.net>) id 1xTfF7-000KaM-0J; Wed, 18 Nov 2026 13:58:29 +0100 X-Received: from localhost ([127.0.0.1]) by sslproxy01.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from <daniel@iogearbox.net>) id 1xTfF6-000PVf-0a; Wed, 18 Nov 2026 13:58:27 +0100 X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: "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> X-In-Reply-To: <20261111005533.6436-8-toddfreed@meta.com> X-Virus-Scanned: Clear (ClamAV 1.4.6/28187/Wed Nov 18 07:28:39 2026) X-Received-Bytes: 11587