From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795910225; b=g+wSnZHAcftuMrqtudZBkjJ+oNFDVt/WslwzQrJJE/w0uehnz3cXmVXw19WcdLdkeQ/S TmdiCwchiQVPnJTHpFjZUOpV6ckNjRTWtySdmNXjhovQ4FHZZL28fiUddAXS7MDMEQv/C fJfjDTCFwd4tTZ7hKLZ4/vtR0giZACNcEij8nfFTuhrRYS6EyICnADoq4C5+fH32fUjar 9otJDIuj59FiyUYkWCJzZu8/helDQLxiW56y5NHZkleF6yJ9wyV5xHT6ZG+eSZyz0Gbsg N8Od6yejFKNxgFkJnX/xp8GbwNdyuifnlVuGknJsmQgyu3Wy+EngAUdWyN/7mZqRw/A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795910225; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=KhnZCrhnqex0WIv0p/EuTJujf5qpPjuUlIroKHGzHQU=; b=UX9oMSrUeQMzW890iF/UZQNDCn8/dxbyWmyzL0j6Q3fzmKJNSIvy16LUv0SXwDbki6gF v10IU3LGnPypHzEFQmgw9l/hS4uReMGm3KxOaUR8nNlWNKMdXJ+cTd7+E6Ll9J3nhCktV yfmX0nu3GZwpPB3HdLiXkxvH55F5kSnm2efSA9otLOWSd45MdnAkz1v574c/4ZvKPbStq EOpoNdqBdl5DFUzlU0kUwe0BUYnKRWXClPN0Bz0ibkz/sq5f1ILm6HSSIbU2HLx6kMm2R Ox5Hac/GpKmqUCAhciL/6C1V2UVrcn8ljfg3nTTephoo3y0fqdlKCQoGKmj11eGS89g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HvJFuQ7v; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18182606A330; Sat, 28 Nov 2026 23:57:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HvJFuQ7v Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8572B1F000C1; Sat, 28 Nov 2026 23:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795910224; bh=KhnZCrhnqex0WIv0p/EuTJujf5qpPjuUlIroKHGzHQU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=HvJFuQ7vxBx1s8G5UhKuxaz658eqUdes1V5lHvFNr3mxQ81l9rJj5/gjhYA/FzIuR gzLHgfBnIck63k8Baaf0u4vIcUPBpfGrFrRDNTCruP02l4zfcTIPaOUx/CAbU2xdbS FVP7EkoFJqv+D6lPorUx/daLwJEbm77d8S/Mg1Rrw11EmVUNR0z2OHROFVSCcSpNwm 7EfJvqrzQvRDwTJ5RjBm2oSzIX0Ofw4Ur9Q5hvesjVSgLVu7njUfDsNItu9TlaZfP6 kh0YwUuZYfvWLve+mIcR+g7i6WHy/l1IS5yu9Fww2PefRkqHqBU939yw8O5fdcnrEF KcMrvosqj6FwA== Subject: Re: [PATCH net-next v3 06/12] net/sched: add act_psp for psp transport mode From: netdev-bot+sashiko@kernel.org To: toddfreed@meta.com Cc: netdev@vger.kernel.org, davem@davemloft.net, andrew+netdev@lunn.ch, bjorn@kernel.org, borisp@nvidia.com, cratiu@nvidia.com, daniel.zahka@gmail.com, donald.hunter@gmail.com, dtatulea@nvidia.com, edumazet@kernel.org, kuba@kernel.org, jhs@mojatatu.com, jiri@resnulli.us, leon@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org, mbloch@nvidia.com, pabeni@redhat.com, pctammela@mojatatu.com, saeedm@nvidia.com, horms@kernel.org, tariqt@nvidia.com, weiwan@google.com, willemdebruijn.kernel@gmail.com, kuniyu@google.com, bpf@vger.kernel.org, ast@fiberby.net, qingfang.deng@linux.dev, toke@redhat.com, shuah@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, matttbe@kernel.org, dsahern@kernel.org, j.koeppeler@tu-berlin.de, hangbin.liu@linux.dev Date: Sat, 28 Nov 2026 23:57:02 +0000 Message-ID: <179591022206.3135.561641643662591036@kernel.org> In-Reply-To: <20261124221758.3230929-7-toddfreed@meta.com> References: <20261124221758.3230929-7-toddfreed@meta.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] Encap marks arbitrary egress packets as device-decrypted, and a later egress-to-ingress redirect delivers them locally with the mark… - [Medium] net/sched: act_psp: METADATA_PSP dst and skb->decrypted split on fragmentation - [Low] The help text for NET_ACT_PSP in net/sched/Kconfig says the action 'Enables transparent psp tunnels for forwarded traffic.' The… -- net/sched: add act_psp for psp transport mode This commit adds a new tc action, act_psp, for PSP transport mode. Encap attaches a PSP Tx association to an egress skb as a METADATA_PSP dst and sets skb->decrypted, so the PSP device encrypts the packet on transmit. Decap removes the PSP Rx state from a packet the device decrypted. > diff --git a/net/sched/Kconfig b/net/sched/Kconfig > index 6ddff028b81a4..35f9d76c4caea 100644 > --- a/net/sched/Kconfig > +++ b/net/sched/Kconfig > @@ -939,6 +939,19 @@ config NET_ACT_GATE > To compile this code as a module, choose M here: the > module will be called act_gate. > > +config NET_ACT_PSP > + tristate "PSP encryption tc action" > + depends on NET_CLS_ACT && INET_PSP > + help > + Say Y here to allow PSP associations, created through the PSP > + netlink family, to be attached to packets. PSP capable devices can > + then encrypt them on transmit. Enables transparent psp tunnels for > + forwarded traffic. [Severity: Low] This isn't a bug, but is "transparent psp tunnels" accurate in the NET_ACT_PSP help text? The action only implements PSP transport mode. It inserts UDP + PSP between L3 and L4, and tcf_psp_set_transport_header() rejects fragments and IPv6 extension headers. The commit message also says "Tunnel mode PSP, which a later series adds". The help text is still the same at the end of the series. [ ... ] > diff --git a/net/sched/act_psp.c b/net/sched/act_psp.c > new file mode 100644 > index 0000000000000..757b15a812a20 > --- /dev/null > +++ b/net/sched/act_psp.c > @@ -0,0 +1,437 @@ [ ... ] > +static int tcf_psp_act(struct sk_buff *skb, const struct tc_action *a, > + struct tcf_result *res) > +{ > + struct tcf_psp *p = to_psp(a); > + struct tcf_psp_params *params; > + > + params = rcu_dereference_bh(p->params); > + > + tcf_lastuse_update(&p->tcf_tm); > + tcf_action_update_bstats(&p->common, skb); > + > + switch (params->psp_action) { > + case TCA_PSP_ACT_ENCAP: > + /* Encap on ingress isn't supported: routing replaces the > + * dst of a packet entering the stack, so it would lose its > + * association before it reaches the PSP device > + */ > + if (unlikely(skb_at_tc_ingress(skb))) > + return tcf_psp_drop(p, skb, SKB_DROP_REASON_PSP_OUTPUT); [ ... ] > + if (unlikely(!tcf_psp_set_transport_header(skb))) > + return tcf_psp_drop(p, skb, SKB_DROP_REASON_PSP_OUTPUT); > + skb_dst_drop(skb); > + skb_dst_set(skb, dst_clone(¶ms->md->dst)); > + /* Must be encrypted: sk_validate_xmit_skb() drops it unless > + * it still carries the association when it is transmitted > + */ > + skb->decrypted = 1; > + break; [Severity: Medium] Can the METADATA_PSP dst and skb->decrypted come apart after tcf_psp_act() has paired them here? The backstop in this comment only works if both stay together, but the fragmentation paths copy only one of them. Suppose act_ct defragmented the packet earlier, so tc_skb_cb(skb)->mru is set. A later mirred redirect then goes through tcf_dev_queue_xmit() -> sch_frag_xmit_hook() -> sch_fragment(). ip_do_fragment() and ip6_fragment() build the fragments with ip_copy_metadata() / ip6_copy_metadata(). Those copy the dst and the skb extensions, but not skb->decrypted. sch_frag_xmit() then puts the saved METADATA_PSP dst back on each fragment with __skb_dst_copy(). Nothing on that path rejects an skb with decrypted set. The new fragments carry the association with decrypted == 0. A later rule on the target device might drop or replace the dst, for example an egress-to-ingress mirred followed by forwarding, or tunnel_key set. sk_validate_xmit_skb() then sees neither skb_psp_md() nor skb_is_decrypted(), and sends the fragment in cleartext instead of dropping it. This action can also reach the same state a second way. ip_copy_metadata() copies SKB_EXT_PSP without decrypted too, so a fragmented Rx PSP packet can arrive with SKB_EXT_PSP and decrypted == 0: - Encap only checks skb_is_decrypted(), not skb_ext_find(skb, SKB_EXT_PSP), so it accepts the packet and sets decrypted. - A decap later in the pipeline sees SKB_EXT_PSP, deletes it and clears skb->decrypted. It doesn't check whether skb_psp_md(skb) is set. That again leaves the METADATA_PSP dst with decrypted == 0. Should encap refuse skbs that carry SKB_EXT_PSP, and should decap leave skb->decrypted alone when the skb has a PSP metadata dst? For the fragmentation case, which fix do you prefer? Encap could drop packets that sch_frag will refragment (tc_skb_cb(skb)->mru set), since transport mode can't encrypt fragments anyway. Or the fragment paths could carry skb->decrypted over. Reaching this needs CAP_NET_ADMIN and a specific pipeline: act_ct defrag, psp encap, mirred, then a step that drops the dst. Still, the commit message says skb->decrypted is set so that a packet losing its association gets dropped, and these paths get around that. The code is still the same at the end of the series. [Severity: Medium] Can a later action in the same rule move this skb to ingress with skb->decrypted still set? tcf_psp_act() returns params->action, which can be TC_ACT_PIPE. The only direction check is skb_at_tc_ingress(), done before encap. With mirred ingress redirect after encap, tcf_mirred_to_dev() clones the skb. The clone keeps the decrypted bit. It then drops the dst: net/sched/act_mirred.c:tcf_mirred_to_dev() { ... if (want_ingress && !at_ingress) /* drop dst for egress -> ingress */ skb_dst_drop(skb_to_send); ... } That removes the METADATA_PSP association, and tcf_mirred_forward() then calls netif_rx(). Neither sk_validate_xmit_skb() nor psp_xmit_md() runs on that path, and nothing on the receive side clears skb->decrypted. The skb then reaches TCP with decrypted set. On a kTLS socket using TLS_HW RX offload: net/tls/tls_device.c:tls_device_decrypted() { ... if (!tls_strp_msg_mixed_decrypted(sw_ctx)) { is_decrypted = skb->decrypted; is_encrypted = !is_decrypted; ... } Would the record then count as already decrypted and authenticated by the NIC, so software decryption and tag verification are skipped? If so, plaintext chosen by whoever controls the tc rule would be accepted as genuine TLS record data. That plaintext could be a frame built with AF_PACKET or rewritten with pedit. The commit message says "Any other device drops it" and that "sk_validate_xmit_skb() drops the packet if it loses the METADATA_PSP dst on the way". Neither holds for a redirect to ingress. A later patch in the series, Documentation/networking/psp.rst, says such a packet is "delivered locally with skb->decrypted still set" and calls this unsupported. The kernel still doesn't prevent it, and the document doesn't cover the kTLS impact. The code is still the same at the end of the series. Reaching this needs all of the following: - CAP_NET_ADMIN in the netns. - A PSP association that the netns can access. - PSP hardware. - A kTLS HW RX socket in the same netns. PSP sockets don't seem affected, because their Rx policy also requires SKB_EXT_PSP, and the forged skb doesn't have it. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124221758.3230929-1-toddfreed%40meta.com