Netdev List
 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, bpf@vger.kernel.org,
	daniel@iogearbox.net, daniel.zahka@gmail.com,
	donald.hunter@gmail.com, edumazet@kernel.org, kuba@kernel.org,
	jhs@mojatatu.com, jiri@resnulli.us, 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.lau@linux.dev, pabeni@redhat.com, saeedm@nvidia.com,
	horms@kernel.org, tariqt@nvidia.com, weiwan@google.com,
	willemdebruijn.kernel@gmail.com
Subject: Re: [PATCH net-next v1 10/15] net/sched: flower: add psp_spi, psp_ver, and psp_dev matches
Date: Sun, 15 Nov 2026 03:18:26 +0000	[thread overview]
Message-ID: <179471270629.2199510.9480561958902023552@kernel.org> (raw)
In-Reply-To: <20261111005533.6436-11-toddfreed@meta.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

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] The commit message misstates what a PSP flower rule matches
  once two key rotations have passed, and it overstates its claim that…

--

net/sched: flower: add psp_spi, psp_ver, and psp_dev matches

This adds a flow dissector key that is filled from the SKB_EXT_PSP Rx
state of decrypted packets. It also adds flower matches on the SPI (with
a mask), the PSP version and the PSP device ID. The goal is to let a tc
rule select the packets of a single Rx association, for example to apply
psp decap.

> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 1be6c739e3c71..95d3fa3b1568e 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c

[ ... ]

> @@ -511,6 +512,32 @@ void skb_flow_dissect_hash(const struct sk_buff *skb,
>  }
>  EXPORT_SYMBOL(skb_flow_dissect_hash);
>  
> +void skb_flow_dissect_psp(const struct sk_buff *skb,
> +			  struct flow_dissector *flow_dissector,
> +			  void *target_container)
> +{
> +#if IS_ENABLED(CONFIG_INET_PSP)
> +	struct flow_dissector_key_psp *key;
> +	struct psp_skb_ext *pse;
> +
> +	if (!dissector_uses_key(flow_dissector, FLOW_DISSECTOR_KEY_PSP))
> +		return;
> +
> +	pse = skb_ext_find(skb, SKB_EXT_PSP);
> +	if (!pse)
> +		return;
> +
> +	key = skb_flow_dissector_target(flow_dissector,
> +					FLOW_DISSECTOR_KEY_PSP,
> +					target_container);
> +	key->spi = pse->spi;
> +	key->dev_id = pse->dev_id;
> +	key->version = pse->version;
> +	key->present = 1;

[Severity: Medium]
Does the commit message describe the right failure mode for rules that
are still installed after two key rotations?

The commit message says:

  Together these matches tie a rule to one association, ...

and:

  this means that a rule matching packets that correspond to an rx
  association which is stale (two rotations have passed), can still match.

After two rotations the device key for the original association is gone.
Its packets then fail to decrypt and never get SKB_EXT_PSP, so the stale
association itself can no longer match.

The SPI value can be handed out again, though. In netdevsim, for example:

drivers/net/netdevsim/psp.c:nsim_key_rotate() {
    ...
	if (ns->psp.spi & PSP_SPI_KEY_PHASE)
		ns->psp.spi = 0;
	else
		ns->psp.spi = PSP_SPI_KEY_PHASE;
    ...
}

and nsim_rx_spi_alloc() then does:

	assoc->spi = cpu_to_be32(++ns->psp.spi);

So a new rx-spi-alloc, possibly for a different peer, can get 0x80000001
again. skb_flow_dissect_psp() only copies spi, dev_id and version. Given
that, wouldn't the example rule from the commit message:

  psp_spi 0x80000001 psp_ver 0 psp_dev 1 action psp decap

strip PSP state from the traffic of a different, live association? With
a mirred action instead of decap, it would forward that traffic.

The socket path avoids this because psp_pse_matches_pas() also compares
the generation:

	return pse && pas->rx.spi == pse->spi &&
	       pas->generation == pse->generation &&
	       pas->version == pse->version &&
	       pas->dev_id == pse->dev_id;

Adding generation to the key would not fully fix this either. The mlx5
Rx path always passes generation = 0 to psp_dev_rcv(). So it looks like
(spi, version, dev) cannot identify a single association beyond two
rotations on any driver.

The "Socket-less associations" text that a later patch in this series
adds to Documentation/networking/psp.rst has the same gap. It only says
userspace should replace such rules before two rotations, and it repeats
that the matches tie a decap rule to one Rx association. No later patch
in the series adds a generation match or any enforcement.

Could the commit message and the documentation say that a stale rule can
end up matching a different association that reused the SPI, rather
than the stale association itself?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261111005533.6436-1-toddfreed%40meta.com

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

Thread overview: 38+ 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-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-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-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-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-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-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 [this message]
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=179471270629.2199510.9480561958902023552@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel.zahka@gmail.com \
    --cc=daniel@iogearbox.net \
    --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