From: netdev-bot+sashiko@kernel.org
To: filzador@gmail.com
Cc: ronak.doshi@broadcom.com, bcm-kernel-feedback-list@broadcom.com,
netdev@vger.kernel.org, bpf@vger.kernel.org,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, ast@kernel.org,
daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com,
sdf@fomichev.me, u9012063@gmail.com
Subject: Re: [PATCH net v3 2/5] vmxnet3: fix the error path of XDP program setup
Date: Sun, 29 Nov 2026 08:27:53 +0000 [thread overview]
Message-ID: <179594087397.3146.5891626181063918087@kernel.org> (raw)
In-Reply-To: <20261125075255.1517-3-filzador@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · 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).
- [High] The new err_close path in vmxnet3_xdp_set()
(drivers/net/vmxnet3/vmxnet3_xdp.c:121-129) can deadlock RTNL against…
--
vmxnet3: fix the error path of XDP program setup
This commit reworks the error handling in vmxnet3_xdp_set(). A failed
attach now drops the new program and restarts the device without XDP, and
a failed detach completes the detach. If the device cannot be restarted,
the interface is closed with dev_close().
> diff --git a/drivers/net/vmxnet3/vmxnet3_xdp.c b/drivers/net/vmxnet3/vmxnet3_xdp.c
> index 5f470499e6002..a57866753d0fb 100644
> --- a/drivers/net/vmxnet3/vmxnet3_xdp.c
> +++ b/drivers/net/vmxnet3/vmxnet3_xdp.c
[ ... ]
> @@ -55,46 +72,61 @@ vmxnet3_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf,
[ ... ]
> + vmxnet3_quiesce_dev(adapter);
> vmxnet3_xdp_exchange_program(adapter, new_bpf_prog);
[ ... ]
> + err = vmxnet3_xdp_restart_dev(adapter);
> + if (err && new_bpf_prog) {
> + /* Attach failed (old_bpf_prog is NULL here): the core drops
> + * its reference to the new program and keeps nothing
> + * attached. Bring the device back up without XDP.
> + */
> + NL_SET_ERR_MSG_MOD(extack, "failed to restart device for XDP");
> + vmxnet3_xdp_exchange_program(adapter, NULL);
> + if (vmxnet3_xdp_restart_dev(adapter))
> + goto err_close;
> + return err;
> }
> - err = vmxnet3_activate_dev(adapter);
> if (err) {
> - NL_SET_ERR_MSG_MOD(extack,
> - "failed to activate device for XDP.");
> - return -EOPNOTSUPP;
> + /* Detach failed. The core may ignore an error here (XDP link
> + * release), so complete the detach on a closed device.
> + */
> + netdev_err(netdev, "XDP removal failed to restart, closing\n");
> + goto err_close;
> }
> clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
[ ... ]
> +err_close:
> + /* The device is left quiesced, with IRQs freed and NAPI disabled,
> + * as vmxnet3_close() expects after a quiesce: close the interface.
> + * vmxnet3_force_close() would quiesce it and free the IRQs again.
> + */
> + dev_close(netdev);
[Severity: High]
Can this dev_close() call deadlock RTNL against vmxnet3_reset_work()?
vmxnet3_xdp_set() runs as ndo_bpf with RTNL held and never takes
VMXNET3_STATE_BIT_RESETTING. dev_close() ends up in vmxnet3_close(), which
waits for that bit with no timeout:
drivers/net/vmxnet3/vmxnet3_drv.c:vmxnet3_close() {
...
while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state))
usleep_range(1000, 2000);
...
}
vmxnet3_reset_work() takes the bit first and RTNL second:
drivers/net/vmxnet3/vmxnet3_drv.c:vmxnet3_reset_work() {
...
if (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state))
return;
/* if the device is closed, we must leave it alone */
rtnl_lock();
...
}
reset_work can be queued by a tx timeout (vmxnet3_tx_timeout()) or a
device error event (vmxnet3_process_events()) while an XDP attach or detach
holds RTNL. If that happens, the sequence could be:
reset_work vmxnet3_xdp_set() (RTNL held)
test_and_set_bit(RESETTING)
rtnl_lock() <- blocks
vmxnet3_quiesce_dev()
vmxnet3_xdp_restart_dev() fails
dev_close()
vmxnet3_close()
spins on RESETTING
The RTNL holder then waits for a bit that only the RTNL waiter can clear.
Both the failed detach path and the failed second restart on the attach
path reach err_close.
Before this patch these failure paths returned -EOPNOTSUPP without calling
dev_close(), so reset_work would eventually get RTNL and run. The commit
message lists "a pending vmxnet3_reset_work() can then hang or crash" as
one of the hazards being fixed. A hang still looks reachable through the
new dev_close() call.
vmxnet3_force_close() guards against this case:
/*
* we must clear VMXNET3_STATE_BIT_RESETTING, otherwise
* vmxnet3_close() will deadlock.
*/
BUG_ON(test_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state));
The err_close comment explains why dev_close() is used instead of
vmxnet3_force_close() in terms of IRQ and NAPI state. It does not cover who
owns RESETTING.
The RESETTING-before-RTNL ordering in vmxnet3_reset_work() is older than
this patch and also affects a plain ifdown, but this patch adds a new path
into it. Would taking rtnl_lock() before test_and_set_bit() in
vmxnet3_reset_work() be a reasonable complementary fix?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125075255.1517-1-filzador%40gmail.com
next prev parent reply other threads:[~2026-11-29 8:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 7:52 [PATCH net v3 0/5] vmxnet3: fix native XDP crash on oversized frames and XDP loss on reset Philipp Sudakas
2026-11-25 7:52 ` [PATCH net v3 1/5] vmxnet3: clear rx_ctx.skb after a data ring XDP verdict Philipp Sudakas
2026-11-25 7:52 ` [PATCH net v3 2/5] vmxnet3: fix the error path of XDP program setup Philipp Sudakas
2026-11-29 8:27 ` netdev-bot+sashiko [this message]
2026-11-25 7:52 ` [PATCH net v3 3/5] vmxnet3: limit the XDP MTU to the rx head buffer size Philipp Sudakas
2026-11-25 7:52 ` [PATCH net v3 4/5] vmxnet3: drop XDP frames that do not fit in one rx buffer Philipp Sudakas
2026-11-29 8:27 ` netdev-bot+sashiko
2026-11-25 7:52 ` [PATCH net v3 5/5] vmxnet3: keep the XDP program across device resets Philipp Sudakas
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=179594087397.3146.5891626181063918087@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=filzador@gmail.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ronak.doshi@broadcom.com \
--cc=sdf@fomichev.me \
--cc=u9012063@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