Linux Documentation
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: daniel.zahka@gmail.com
Cc: kuba@kernel.org, willemdebruijn.kernel@gmail.com,
	davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com,
	horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org,
	rdunlap@infradead.org, donald.hunter@gmail.com,
	andrew+netdev@lunn.ch, shuah@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kselftest@vger.kernel.org, willemb@google.com
Subject: Re: [PATCH net-next v4 1/5] psp: support rx rekey operation
Date: Wed, 18 Nov 2026 06:05:03 +0000	[thread overview]
Message-ID: <179498190320.3136.17281959209989358635@kernel.org> (raw)
In-Reply-To: <20261116-psp-v4-1-1a599df2aefa@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] At this commit, Documentation/networking/psp.rst says a PSP Full
  connection can be rekeyed in place 'using the same netlink calls as in…
- [Low] The new field pas->prev_generation is written with a plain read-
  modify-write (`pas->prev_generation |= ~PSP_GEN_VALID_MASK`) in…

--

psp: support rx rekey operation

This commit lets rx-assoc run on a socket that already has PSP state.
It creates a new psp_assoc that keeps the existing Tx state and gets new
Rx state. The previous Rx SPI and generation are kept as a fallback, so
packets the peer sends with the old key are still accepted until the
next Rx rekey or device key rotation.

> diff --git a/Documentation/networking/psp.rst b/Documentation/networking/psp.rst
> index 0f9b6b73f2447..fab797506b0a9 100644
> --- a/Documentation/networking/psp.rst
> +++ b/Documentation/networking/psp.rst
> @@ -140,14 +140,33 @@ The PSP assoc state of a socket is not reset when the connection is
>  torn down. ``connect()`` on a socket that has PSP assoc state will
>  return ``-EINVAL``.
>  
> +Rekeying
> +--------
> +
> +A connection which has completed the exchange described above and is
> +in the "PSP Full" state can be rekeyed in place without being torn
> +down, using the same netlink calls as in connection setup.

[Severity: Low]
Is this accurate at this point in the series?

To finish the rekey, the peer has to install the new SPI and key with
tx-assoc. At this commit, psp_sock_assoc_set_tx() in net/psp/psp_sock.c
still rejects tx-assoc on a socket that already has a Tx key:

	if (pas->tx.spi) {
		NL_SET_ERR_MSG(extack, "Tx key already set");
		err = -EBUSY;
		goto exit_unlock;
	}

An application on a kernel at exactly this commit that follows this
text, or the updated "Applications are expected to rekey their
connections" wording in the Rotation notifications section, would get
-EBUSY from tx-assoc on the peer.

Later patches in the series close this gap:

- "psp: support tx rekey operation" replaces this branch with a call to
  psp_sock_tx_rekey().
- "psp: defer tx key deletions for SADB drivers" removes the temporary
  -EOPNOTSUPP for SADB drivers.
- "selftests: drv-net: psp: add rekey tests" adds test coverage.

The final psp.rst also documents the tx-assoc rekey path.

Could the documentation changes move to the tx rekey patch, so that the
docs match the code at each commit?

[ ... ]

> diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
> index f2cba3fa3a235..c1e38845f08c3 100644
> --- a/net/psp/psp_sock.c
> +++ b/net/psp/psp_sock.c

[ ... ]

> @@ -302,8 +333,21 @@ void psp_assocs_key_rotated(struct psp_dev *psd)
>  	 */
>  	list_for_each_entry_safe(pas, next, &psd->prev_assocs, assocs_list) {
>  		pas->generation |= ~PSP_GEN_VALID_MASK;
> +		pas->prev_generation |= ~PSP_GEN_VALID_MASK;
>  		psd->stats.stales++;
>  	}
> +
> +	/* Don't allow SPI from two generations ago to alias one from the
> +	 * current generation. Rx rekeying under the same device key generation
> +	 * is currently permitted, so skip if the previous SPI is from just one
> +	 * generation ago.
> +	 */
> +	list_for_each_entry(pas, &psd->active_assocs, assocs_list) {
> +		if ((pas->rx.spi ^ pas->prev_spi) &
> +		    cpu_to_be32(PSP_SPI_KEY_PHASE))
> +			pas->prev_generation |= ~PSP_GEN_VALID_MASK;
> +	}

[Severity: Low]
Should these updates to pas->prev_generation use WRITE_ONCE(), with a
matching READ_ONCE() on the reader side?

psp_assocs_key_rotated() holds only psd->lock here. The field is read
without that lock in psp_pse_matches_pas():

	(pas->prev_spi && pas->prev_spi == pse->spi &&
	 pas->prev_generation == pse->generation));

There are two paths to that reader, and neither takes psd->lock:

- __psp_sk_rx_policy_check() from tcp_v4_do_rcv()/tcp_v6_do_rcv(),
  under the socket lock.
- psp_twsk_rx_policy_check() from tcp_v4_rcv()/tcp_v6_rcv() and
  tcp_timewait_state_process(), under RCU only.

These are compound read-modify-write stores, so KCSAN can report them
even with CONFIG_KCSAN_ASSUME_PLAIN_WRITES_ATOMIC.

pas->generation already uses the same unannotated pattern. This patch
adds a new field and a new writer loop over assocs that are attached to
live sockets.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-psp-v4-0-1a599df2aefa%40gmail.com

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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 12:04 [PATCH net-next v4 0/5] psp: support rekeying psp protected tcp connections Daniel Zahka
2026-11-16 12:04 ` [PATCH net-next v4 1/5] psp: support rx rekey operation Daniel Zahka
2026-11-18  6:05   ` netdev-bot+sashiko [this message]
2026-11-16 12:04 ` [PATCH net-next v4 2/5] psp: support tx " Daniel Zahka
2026-11-18  6:05   ` netdev-bot+sashiko
2026-11-16 12:04 ` [PATCH net-next v4 3/5] psp: defer tx key deletions for SADB drivers Daniel Zahka
2026-11-18  6:05   ` netdev-bot+sashiko
2026-11-16 12:04 ` [PATCH net-next v4 4/5] selftests: drv-net: psp: factor out psp connection setup Daniel Zahka
2026-11-16 12:04 ` [PATCH net-next v4 5/5] selftests: drv-net: psp: add rekey tests Daniel Zahka
2026-11-18  6:05   ` 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=179498190320.3136.17281959209989358635@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=corbet@lwn.net \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=willemb@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