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 v2 2/5] vmxnet3: keep the previous XDP program when attaching fails
Date: Tue, 24 Nov 2026 13:26:27 +0000 [thread overview]
Message-ID: <179552678713.3135.6451619234057473485@kernel.org> (raw)
In-Reply-To: <20261123124855.1021-3-filzador@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 (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_restore path in vmxnet3_xdp_set()
(drivers/net/vmxnet3/vmxnet3_xdp.c:100-109) puts old_bpf_prog back…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the
err_restore path added here only restores software state:…
--
vmxnet3: keep the previous XDP program when attaching fails
This patch changes vmxnet3_xdp_set() so the old program's reference is
released only after the device has been reactivated. If
vmxnet3_rq_create_all() or vmxnet3_activate_dev() fails, the new
err_restore path puts the old program back in adapter->xdp_bpf_prog and
restores the redirect-target feature.
> diff --git a/drivers/net/vmxnet3/vmxnet3_xdp.c b/drivers/net/vmxnet3/vmxnet3_xdp.c
> index 5f470499e6002..45259b236ebd7 100644
> --- a/drivers/net/vmxnet3/vmxnet3_xdp.c
> +++ b/drivers/net/vmxnet3/vmxnet3_xdp.c
[ ... ]
> @@ -84,17 +82,31 @@ vmxnet3_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf,
> if (err) {
> NL_SET_ERR_MSG_MOD(extack,
> "failed to re-create rx queues for XDP.");
> - return -EOPNOTSUPP;
> + goto err_restore;
> }
> err = vmxnet3_activate_dev(adapter);
> if (err) {
> NL_SET_ERR_MSG_MOD(extack,
> "failed to activate device for XDP.");
> - return -EOPNOTSUPP;
> + goto err_restore;
> }
> clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
>
> +out:
> + if (old_bpf_prog)
> + bpf_prog_put(old_bpf_prog);
> return 0;
> +
> +err_restore:
> + /* On error the core drops its reference to the new program and
> + * keeps the old one attached: the driver must keep the old one.
> + */
> + vmxnet3_xdp_exchange_program(adapter, old_bpf_prog);
[Severity: High]
The comment says the core keeps the old program attached on error. Does
that hold for every caller of ndo_bpf?
An XDP link detach goes through bpf_xdp_link_release() or
bpf_xdp_link_detach(), then dev_xdp_detach_link(). That function ignores
the driver's return value:
net/core/dev.c:dev_xdp_detach_link() {
...
bpf_op = dev_xdp_bpf_op(dev, mode);
WARN_ON(dev_xdp_install(dev, mode, bpf_op, NULL, 0, NULL));
dev_xdp_set_link(dev, mode, NULL);
return 0;
}
On that path, vmxnet3_xdp_set() is called with new_bpf_prog == NULL and
old_bpf_prog == P, so need_update is true on a running device.
Suppose vmxnet3_rq_create_all() or vmxnet3_activate_dev() fails. Then
err_restore puts P back into adapter->xdp_bpf_prog and keeps the
reference. The core, however, has already cleared its record of the
program.
What releases that reference afterwards? vmxnet3 has no other
bpf_prog_put(). At unregister, dev_xdp_uninstall() skips modes that have
no program in the core:
prog = dev_xdp_prog(dev, mode);
if (!prog)
continue;
So ndo_bpf is never called again, and P and its maps stay pinned until
another program is attached.
Can P also keep running on received traffic? QUIESCED stays set, so a
later vmxnet3_close() skips quiesce. On the next open,
vmxnet3_open()->vmxnet3_activate_dev()->vmxnet3_rq_init() would see
vmxnet3_xdp_enabled() and run P, while ip link shows no XDP program.
Before this patch, the driver dropped P and left xdp_bpf_prog NULL on
this path, which matched the core's forced detach.
This looks unchanged later in the series. The later commit "vmxnet3:
keep the XDP program across device resets" does not touch err_restore.
Should a call with new_bpf_prog == NULL always leave the driver without
the program and without its reference, even when it fails?
> + if (old_bpf_prog)
> + xdp_features_set_redirect_target(netdev, false);
> + else
> + xdp_features_clear_redirect_target(netdev);
> + return -EOPNOTSUPP;
[Severity: High]
This is a pre-existing issue, not one introduced by this patch, but
err_restore only restores software state.
By the time err_restore runs, the following has already happened:
- vmxnet3_quiesce_dev() has disabled NAPI on every rx queue, freed the
IRQs and set QUIESCED.
- vmxnet3_reset_dev() has reset the device.
- The rx rings have been destroyed. If vmxnet3_rq_create_all() is what
failed, its err_out path destroys them a second time.
The function then returns with netif_running() still true. The interface
stays up with no RX or TX. The restored program does not actually run
until the interface is taken down and brought back up.
vmxnet3_change_mtu() runs the same sequence and closes the device when
these steps fail:
out:
clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state);
if (err)
vmxnet3_force_close(adapter);
Can later operations misbehave on an interface left in this state?
vmxnet3_suspend() sees netif_running() and calls napi_disable() on NAPI
instances that are already disabled:
for (i = 0; i < adapter->num_rx_queues; i++)
napi_disable(&adapter->rx_queue[i].napi);
That would loop forever in napi_disable_locked() and hang system suspend.
There is also a failure after vmxnet3_rq_create_all() fails.
vmxnet3_resume() and a pending vmxnet3_reset_work() both call
vmxnet3_activate_dev() without re-creating the rings. vmxnet3_rq_init()
would then write through rq->buf_info[0][i] while buf_info[0] is NULL.
vmxnet3_reset_work() can already be waiting at this point. It sets
RESETTING before rtnl_lock(), so it can be queued (by tx_timeout or a
TQERR/RQERR event) and wait for RTNL while vmxnet3_xdp_set() runs.
vmxnet3_xdp_set() never sets RESETTING itself.
Should vmxnet3_xdp_set() call vmxnet3_force_close() on these failures,
as vmxnet3_change_mtu() does?
> }
>
> /* This is the main xdp call used by kernel to set/unset eBPF program. */
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123124855.1021-1-filzador%40gmail.com
next prev parent reply other threads:[~2026-11-24 13:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 12:48 [PATCH net v2 0/5] vmxnet3: fix native XDP crash on oversized frames and XDP loss on reset Philipp Sudakas
2026-11-23 12:48 ` [PATCH net v2 1/5] vmxnet3: clear rx_ctx.skb after a data ring XDP verdict Philipp Sudakas
2026-11-23 12:48 ` [PATCH net v2 2/5] vmxnet3: keep the previous XDP program when attaching fails Philipp Sudakas
2026-11-24 13:26 ` netdev-bot+sashiko [this message]
2026-11-23 12:48 ` [PATCH net v2 3/5] vmxnet3: limit the XDP MTU to the rx head buffer size Philipp Sudakas
2026-11-23 12:48 ` [PATCH net v2 4/5] vmxnet3: drop XDP frames that do not fit in one rx buffer Philipp Sudakas
2026-11-24 13:26 ` netdev-bot+sashiko
2026-11-23 12:48 ` [PATCH net v2 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=179552678713.3135.6451619234057473485@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