mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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
Subject: Re: [PATCH net-next v3 06/12] net/sched: add act_psp for psp transport mode
Date: Sat, 28 Nov 2026 23:57:02 +0000	[thread overview]
Message-ID: <179591022206.3135.561641643662591036@kernel.org> (raw)
In-Reply-To: <20261124221758.3230929-7-toddfreed@meta.com>

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(&params->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

  parent reply	other threads:[~2026-11-28 23:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 22:17 [PATCH net-next v3 00/12] psp: introduce socket-less associations Todd Freed
2026-11-24 22:17 ` [PATCH net-next v3 01/12] psp: get netns from net_device instead of sock Todd Freed
2026-11-24 22:17 ` [PATCH net-next v3 02/12] psp: take the psp nexthdr from the packet on encap Todd Freed
2026-11-26 14:32   ` Björn Töpel
2026-11-24 22:17 ` [PATCH net-next v3 03/12] psp: declare psp_assoc_set_tx() in psp.h Todd Freed
2026-11-24 22:17 ` [PATCH net-next v3 04/12] psp: add support for socket-less psp associations Todd Freed
2026-11-26 15:07   ` Björn Töpel
2026-11-24 22:17 ` [PATCH net-next v3 05/12] net: add METADATA_PSP dst to carry a psp association on an skb Todd Freed
2026-11-26 15:27   ` Björn Töpel
2026-11-28 23:56   ` netdev-bot+sashiko
2026-11-24 22:17 ` [PATCH net-next v3 06/12] net/sched: add act_psp for psp transport mode Todd Freed
2026-11-26 15:45   ` Björn Töpel
2026-11-28 23:57   ` netdev-bot+sashiko [this message]
2026-11-24 22:17 ` [PATCH net-next v3 07/12] net/sched: flower: add psp_spi, psp_ver, and psp_dev matches Todd Freed
2026-11-28 23:57   ` netdev-bot+sashiko
2026-11-24 22:17 ` [PATCH net-next v3 08/12] selftests: drv-net: psp: test socket-less associations and the tc psp action Todd Freed
2026-11-28 23:57   ` netdev-bot+sashiko
2026-11-24 22:17 ` [PATCH net-next v3 09/12] selftests: drv-net: psp: test that software encap on ingress drops Todd Freed
2026-11-24 22:17 ` [PATCH net-next v3 10/12] selftests: tc-testing: run dependsOn probes outside the test namespace Todd Freed
2026-11-28 23:57   ` netdev-bot+sashiko
2026-11-24 22:17 ` [PATCH net-next v3 11/12] selftests: tc-testing: add tests for the psp action Todd Freed
2026-11-24 22:17 ` [PATCH net-next v3 12/12] Documentation: networking: psp: document socket-less associations Todd Freed
2026-11-28 23:57   ` netdev-bot+sashiko

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=179591022206.3135.561641643662591036@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@fiberby.net \
    --cc=bjorn@kernel.org \
    --cc=borisp@nvidia.com \
    --cc=bpf@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=cratiu@nvidia.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=hangbin.liu@linux.dev \
    --cc=horms@kernel.org \
    --cc=j.koeppeler@tu-berlin.de \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=leon@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=matttbe@kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pctammela@mojatatu.com \
    --cc=qingfang.deng@linux.dev \
    --cc=rdunlap@infradead.org \
    --cc=saeedm@nvidia.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tariqt@nvidia.com \
    --cc=toddfreed@meta.com \
    --cc=toke@redhat.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®