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 v5 4/6] psp: defer tx key deletions for SADB drivers
Date: Sat, 21 Nov 2026 23:03:02 +0000 [thread overview]
Message-ID: <179530218277.3135.14647055020229146998@kernel.org> (raw)
In-Reply-To: <20261118-psp-v5-4-b9ec840e0296@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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] With the -EOPNOTSUPP guard gone from psp_sock_tx_rekey()
(net/psp/psp_sock.c), any unprivileged owner of an established PSP TCP…
- [Low] The applied commit message does not say that this patch turns on
Tx rekey for SADB devices.
- [Low] The kernel-doc for psp_dev_ops::tx_key_add and ::tx_key_del in
include/net/psp/types.h still says only that each callback 'Can be…
--
psp: defer tx key deletions for SADB drivers
This patch adds a deferred Tx key deletion queue for PSP devices that
store Tx keys in an SADB. Before calling psp_dev_tx_key_del(), the core
snapshots BQL queued byte counts per Tx queue and polls until those bytes
have completed. It also removes the -EOPNOTSUPP restriction on Tx rekey
for SADB devices and makes CONFIG_INET_PSP depend on CONFIG_BQL.
> diff --git a/net/psp/psp_main.c b/net/psp/psp_main.c
> index ba44154cf8dc0..789315dae2373 100644
> --- a/net/psp/psp_main.c
> +++ b/net/psp/psp_main.c
[ ... ]
> @@ -75,7 +77,8 @@ psp_dev_create(struct net_device *netdev,
> !psd_ops->rx_spi_alloc ||
> !psd_ops->get_stats ||
> (!psd_ops->tx_key_add != !psd_ops->tx_key_del) ||
> - (psd_caps->assoc_drv_spc && !psd_ops->tx_key_add)))
> + (psd_caps->assoc_drv_spc && !psd_ops->tx_key_add) ||
> + (psd_ops->tx_key_add && !netdev_need_ops_lock(netdev))))
> return ERR_PTR(-EINVAL);
[Severity: Low]
Should the kernel-doc for tx_key_add and tx_key_del in
include/net/psp/types.h be updated along with this check? It still only
says:
* @tx_key_add: add a Tx key to the device
* Install an association in the device. Core will allocate space
* for the driver to use at drv_data.
* Can be left NULL if device does not store Tx keys and @tx_key_del
* is also NULL.
With this patch, a driver that implements these callbacks needs an ops
locked netdev. Without one, psp_dev_create() hits the WARN_ON and returns
-EINVAL.
The driver also needs exact, in-order BQL accounting and has to follow
the dql_reset() and real_num_tx_queues rules that psp_deferred_del_work()
relies on.
These rules are only written down in Documentation/networking/psp.rst,
and the ops kernel-doc doesn't point there. A driver written from the
struct documentation alone could hit the registration WARN, stall the
grace period, or end it too early.
Could the kernel-doc reference the new "Deferred Tx key deletion"
section? No later patch in the series appears to update it.
> diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
> index d497f41c483e1..8de313805af03 100644
> --- a/net/psp/psp_sock.c
> +++ b/net/psp/psp_sock.c
[ ... ]
> @@ -287,10 +302,6 @@ psp_sock_tx_rekey(struct sock *sk, struct psp_dev *psd, struct psp_assoc *pas,
> struct psp_assoc *new;
> int err;
>
> - if (psp_dev_has_sadb(psd)) {
> - NL_SET_ERR_MSG(extack, "Tx rekey not supported on this device");
> - return -EOPNOTSUPP;
> - }
> if (!pas->peer_tx) {
> NL_SET_ERR_MSG(extack, "Socket PSP state is not fully established");
> return -EBUSY;
[Severity: Low]
This isn't a bug, but could the commit message say outright that Tx
rekey is now allowed on SADB devices?
The earlier commit "psp: support tx rekey operation" said SADB drivers
would "return -EOPNOTSUPP for now". With this guard removed,
PSP_CMD_TX_ASSOC on a socket that already has a Tx key now succeeds on
mlx5, where it used to fail.
The only explicit mention is "allow tx rekey on SADB devices" in the v2
changelog below the --- line, and that part is dropped when the patch is
applied.
The same goes for the new registration requirement in psp_dev_create():
(psd_ops->tx_key_add && !netdev_need_ops_lock(netdev))
The body only says drivers "must meet the requirements in
Documentation/networking/psp.rst".
> @@ -322,6 +333,7 @@ psp_sock_tx_rekey(struct sock *sk, struct psp_dev *psd, struct psp_assoc *pas,
> list_move(&pas->assocs_list, &psd->stale_assocs);
>
> rcu_assign_pointer(sk->psp_assoc, new);
> + pas->flags |= PSP_ASSOC_DEFER_TX_KEY_DEL;
> psp_assoc_put(pas);
>
> return 0;
[Severity: Medium]
Can an unprivileged user use up the device's hardware Tx key pool
through this path?
PSP_CMD_TX_ASSOC has no GENL_ADMIN_PERM. psp_sock_assoc_set_tx() enters
psp_sock_tx_rekey() whenever pas->tx.spi is already set, and each call
allocates a new hardware key:
psp_sock_tx_rekey()
psp_assoc_set_tx()
psp_dev_tx_key_add()
mlx5e_psp_assoc_add()
mlx5_create_encryption_key()
The old key then goes onto the deferred deletion queue, which has no
upper bound:
net/psp/psp_deferred_del.c:psp_deferred_del_queue() {
list_move_tail(&pas->assocs_list, &psd->tx_del.next);
schedule_delayed_work(&psd->tx_del.work, 0);
}
psp_deferred_del_work() handles one grace period at a time and polls
every PSP_TX_GRACE_POLL_MS (1000 ms). Keys queued during a grace period
wait for the next one. A single socket can therefore pin as many DEKs as
it can rekey in that window, where before each socket held at most one.
Suppose a queue below real_num_tx_queues never completes the bytes
snapshotted in psp_tx_grace_start(). Would every later rekey then pin a
DEK, a psp_assoc and a psd reference until psp_dev_unregister()?
When a grace period does end, psp_deferred_del_work() calls
psp_dev_tx_key_del() for the whole batch while holding psd->lock. On mlx5
each call is a firmware command:
list_for_each_entry(pas, &to_free, assocs_list)
psp_dev_tx_key_del(psd, pas);
Would that block other PSP netlink operations, and psp_assoc_free() for
every socket on the device, until the batch is done?
The psp_assoc allocation uses GFP_KERNEL_ACCOUNT, but the hardware DEK
pool is shared by the whole device and is not charged to any cgroup. One
local user could make tx_key_add fail for other users' sockets. That
includes sockets in other netns that were delegated the same device.
The commit message acknowledges this ("users should avoid presenting PSP
devices to users they don't trust to abuse this"). In the main netns,
though, every local user can reach the device. Nothing later in the
series appears to change these paths.
Is a cap on the deferred queue length, or a per-socket rate limit,
needed before SADB rekey is allowed?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118-psp-v5-0-b9ec840e0296%40gmail.com
next prev parent reply other threads:[~2026-11-21 23:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 14:08 [PATCH net-next v5 0/6] psp: support rekeying psp protected tcp connections Daniel Zahka
2026-11-18 14:08 ` [PATCH net-next v5 1/6] psp: support rx rekey operation Daniel Zahka
2026-11-21 23:03 ` netdev-bot+sashiko
2026-11-18 14:08 ` [PATCH net-next v5 2/6] psp: support tx " Daniel Zahka
2026-11-18 14:08 ` [PATCH net-next v5 3/6] psp: document lock ordering with the netdev instance lock Daniel Zahka
2026-11-18 14:08 ` [PATCH net-next v5 4/6] psp: defer tx key deletions for SADB drivers Daniel Zahka
2026-11-21 23:03 ` netdev-bot+sashiko [this message]
2026-11-18 14:08 ` [PATCH net-next v5 5/6] selftests: drv-net: psp: factor out psp connection setup Daniel Zahka
2026-11-18 14:08 ` [PATCH net-next v5 6/6] selftests: drv-net: psp: add rekey tests Daniel Zahka
2026-11-21 23:03 ` 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=179530218277.3135.14647055020229146998@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
all inboxes | Powered by JetHome®