From: sashiko-bot@kernel.org
To: "Philipp Sudakas" <filzador@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v2 2/5] vmxnet3: keep the previous XDP program when attaching fails
Date: Tue, 24 Nov 2026 12:49:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-231177@kernel.org> (raw)
In-Reply-To: <20261123124855.1021-3-filzador@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] vmxnet3: incomplete error recovery in vmxnet3_xdp_set()
leaves device broken
- [Medium] vmxnet3: wrong redirect target feature rollback in
vmxnet3_xdp_set()
--
commit 45dfb991794383051e0025dc90fc6eacbd3d1177
Author: Philipp Sudakas <filzador@gmail.com>
vmxnet3: keep the previous XDP program when attaching fails
This commit defers releasing the old XDP program in vmxnet3_xdp_set() until
queue recreation and device activation succeed, and restores the old program
and redirect target feature on failure.
> 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
> @@ -66,11 +66,9 @@ vmxnet3_xdp_set(struct net_device *netdev, struct netdev_bpf *bpf,
> vmxnet3_quiesce_dev(adapter);
>
> vmxnet3_xdp_exchange_program(adapter, new_bpf_prog);
> - if (old_bpf_prog)
> - bpf_prog_put(old_bpf_prog);
>
> if (!running || !need_update)
> - return 0;
> + goto out;
>
> if (new_bpf_prog)
> xdp_features_set_redirect_target(netdev, false);
> @@ -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: Medium]
Does returning from err_restore leave netdev running while the device is
quiesced and its rx queues are destroyed?
Before vmxnet3_rq_create_all() runs, vmxnet3_quiesce_dev() disables NAPI
and frees IRQs, and vmxnet3_rq_destroy_all() frees rq->buf_info[0].
Returning without either reactivating the device or closing it via
vmxnet3_force_close() (as vmxnet3_change_mtu() and vmxnet3_set_ringparam()
do) leaves netif_running(netdev) true on a torn-down device, so a later
vmxnet3_reset_work() or vmxnet3_resume() dereferences NULL rq->buf_info[0]
in vmxnet3_rq_init(), and vmxnet3_suspend() hangs in napi_disable().
In addition, when a failed detach (new_bpf_prog == NULL) restores
adapter->xdp_bpf_prog to old_bpf_prog, a subsequent XDP program
replacement sees need_update == false and returns 0 without recreating the
destroyed rx queues. If the failed detach came from
bpf_xdp_link_release() -> dev_xdp_detach_link(), the core only wraps
dev_xdp_install() in WARN_ON() and unconditionally clears the link, so
skipping bpf_prog_put(old_bpf_prog) leaks the reference and leaves a stale
pointer in adapter->xdp_bpf_prog.
> + if (old_bpf_prog)
> + xdp_features_set_redirect_target(netdev, false);
> + else
> + xdp_features_clear_redirect_target(netdev);
> + return -EOPNOTSUPP;
> }
[Severity: Medium]
When attaching the first XDP program (old_bpf_prog == NULL) fails, does
err_restore clear NETDEV_XDP_ACT_NDO_XMIT even though it was set before
vmxnet3_xdp_set() ran?
vmxnet3_probe_device() initializes netdev->xdp_features with
NETDEV_XDP_ACT_NDO_XMIT enabled:
drivers/net/vmxnet3/vmxnet3_drv.c:vmxnet3_probe_device() {
...
netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
NETDEV_XDP_ACT_NDO_XMIT;
...
}
Calling xdp_features_clear_redirect_target() when old_bpf_prog is NULL
strips that initial flag on a failed attach. Updating the redirect target
feature only after vmxnet3_activate_dev() succeeds would avoid mutating
netdev->xdp_features or emitting NETDEV_XDP_FEAT_CHANGE notifications on
failure.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123124855.1021-1-filzador@gmail.com?part=2
next prev parent reply other threads:[~2026-11-24 12:49 UTC|newest]
Thread overview: 10+ 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 12:49 ` sashiko-bot [this message]
2026-11-24 13:26 ` netdev-bot+sashiko
2026-11-25 7:51 ` Филипп Судакас
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=sashiko-outbox-231177@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=filzador@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.