From: sashiko-bot@kernel.org
To: "Long Li" <longli@microsoft.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH net-next v2 05/13] net: mana: swap queue sets in mana_change_mtu
Date: Fri, 14 Aug 2026 05:05:18 +0000 [thread overview]
Message-ID: <20260814050518.805D11F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260813050418.2906468-6-longli@microsoft.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] mana_xdp_set() is vulnerable to a race condition with RDMA vport creation because it continues to use the legacy mana_detach()/mana_attach() sequence without blocking RDMA, leaving the interface permanently down if a race occurs.
--
--- Patch [5]: [PATCH net-next v2 05/13] net: mana: swap queue sets in mana_change_mtu ---
commit 07ab252b810cb193b26b16516fc0a40653d2b458
Author: Long Li <longli@microsoft.com>
net: mana: swap queue sets in mana_change_mtu
The RX buffer layout depends on the MTU, so changing it rebuilds the
queues. Convert mana_change_mtu() to pre-allocate and swap.
The MTU becomes part of the queue-set configuration, so a new set can be
built for the new MTU while the running one still serves traffic at the
old one, and ndev->mtu is updated only once the new set is live.
Previously it was written before mana_attach() and rolled back on
failure, so a failed change was briefly visible to the stack.
> diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c
> index c0f31b386536a..c858a58577dfb 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_en.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
> @@ -884,35 +884,49 @@ int mana_pre_alloc_rxbufs(struct mana_port_context *mpc, int new_mtu, int num_qu
> return -ENOMEM;
> }
>
> +/* ndev->mtu is updated only once the new set is live (mana_publish_qset), so
> + * a failed allocation leaves the queues and the advertised MTU untouched.
> + */
> static int mana_change_mtu(struct net_device *ndev, int new_mtu)
> {
> struct mana_port_context *mpc = netdev_priv(ndev);
> - unsigned int old_mtu = ndev->mtu;
> + struct mana_port_context *scratch;
> + struct mana_qset newq, oldq;
> int err;
>
> - /* Pre-allocate buffers to prevent failure in mana_attach later */
> - err = mana_pre_alloc_rxbufs(mpc, new_mtu, mpc->num_queues);
> - if (err) {
> - netdev_err(ndev, "Insufficient memory for new MTU\n");
> - return err;
> + /* Port is down: no queues to rebuild, just record the new MTU.
> + * mana_open() will size the RX buffers accordingly.
> + */
> + if (!mpc->port_is_up) {
> + mpc->configured_mtu = new_mtu;
> + WRITE_ONCE(ndev->mtu, new_mtu);
> + return 0;
> }
>
> - err = mana_detach(ndev, false);
> - if (err) {
> - netdev_err(ndev, "mana_detach failed: %d\n", err);
> - goto out;
> - }
[Severity: High]
This isn't a bug introduced by this patch, but since it converts
mana_change_mtu() to avoid the mana_detach()/mana_attach() sequence, is
mana_xdp_set() still vulnerable to a race condition with RDMA vport creation?
Looking at mana_xdp_set() in drivers/net/ethernet/microsoft/mana/mana_bpf.c,
it still uses the legacy detach/attach pattern without blocking RDMA:
err = mana_detach(ndev, false);
if (err) {
netdev_err(ndev,
"mana_detach failed at xdp set: %d\n", err);
NL_SET_ERR_MSG_MOD(extack,
"XDP: Re-config failed at detach");
goto err_dealloc_rxbuffs;
}
err = mana_attach(ndev);
Because mana_xdp_set() drops vport_use_count to 0 without holding vport_mutex
or setting channel_changing = true, couldn't an RDMA application successfully
acquire the vport in the middle of XDP reconfiguration?
If a race occurs, mana_attach() would fail with -EBUSY because RDMA owns the
vport, leaving the Ethernet port permanently down and requiring manual
intervention to recover.
> - WRITE_ONCE(ndev->mtu, new_mtu);
> + scratch = mana_qset_scratch_alloc(mpc);
> + if (!scratch)
> + return -ENOMEM;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260813050418.2906468-1-longli@microsoft.com?part=5
next prev parent reply other threads:[~2026-08-14 5:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 5:04 [PATCH net-next v2 00/13] net: mana: reconfigure by replacing the queue set Long Li
2026-08-13 5:04 ` [PATCH net-next v2 01/13] net: mana: add queue-set allocation and teardown helpers Long Li
2026-08-14 5:05 ` sashiko-bot
2026-08-13 5:04 ` [PATCH net-next v2 02/13] net: mana: swap queue sets in mana_set_channels Long Li
2026-08-14 5:05 ` sashiko-bot
2026-08-13 5:04 ` [PATCH net-next v2 03/13] net: mana: swap queue sets in mana_set_ringparam Long Li
2026-08-14 5:05 ` sashiko-bot
2026-08-13 5:04 ` [PATCH net-next v2 04/13] net: mana: swap queue sets in mana_set_priv_flags Long Li
2026-08-14 5:05 ` sashiko-bot
2026-08-13 5:04 ` [PATCH net-next v2 05/13] net: mana: swap queue sets in mana_change_mtu Long Li
2026-08-14 5:05 ` sashiko-bot [this message]
2026-08-13 5:04 ` [PATCH net-next v2 06/13] net: mana: swap queue sets in mana_xdp_set Long Li
2026-08-13 5:04 ` [PATCH net-next v2 07/13] net: mana: do not bail out of mana_detach on dealloc failure Long Li
2026-08-14 5:05 ` sashiko-bot
2026-08-13 5:04 ` [PATCH net-next v2 08/13] net: mana: keep per-queue statistics in the port context Long Li
2026-08-14 5:05 ` sashiko-bot
2026-08-13 5:04 ` [PATCH net-next v2 09/13] net: mana: share the EQ pool across a queue-set swap Long Li
2026-08-13 5:04 ` [PATCH net-next v2 10/13] net: mana: release EQs left idle by a channel-count reduction Long Li
2026-08-13 5:04 ` [PATCH net-next v2 11/13] net: mana: keep a user-configured RSS table across a queue rebuild Long Li
2026-08-14 5:05 ` sashiko-bot
2026-08-13 5:04 ` [PATCH net-next v2 12/13] net: mana: keep the surviving queues when the channel count is reduced Long Li
2026-08-13 5:04 ` [PATCH net-next v2 13/13] net: mana: keep the existing queues when the channel count is raised Long Li
-- strict thread matches above, loose matches on Subject: below --
2026-08-11 6:34 [PATCH net-next v2 00/13] net: mana: reconfigure by replacing the queue set Long Li
2026-08-11 6:35 ` [PATCH net-next v2 05/13] net: mana: swap queue sets in mana_change_mtu Long Li
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=20260814050518.805D11F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=sashiko-reviews@lists.linux.dev \
/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