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, kuba@kernel.org
Subject: Re: [PATCH net 2/2] vmxnet3: keep the XDP program across device resets
Date: Mon, 23 Nov 2026 01:06:17 +0000 [thread overview]
Message-ID: <179539597786.3135.350150131775018719@kernel.org> (raw)
In-Reply-To: <20261122002847.616-3-filzador@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 1 · High: 0 · 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).
- [Critical] On a failed XDP attach, the patch leaves a dangling bpf_prog
pointer in adapter->xdp_bpf_prog.
--
vmxnet3: keep the XDP program across device resets
This patch stops vmxnet3_rq_cleanup_all() from clearing
adapter->xdp_bpf_prog. The attached XDP program then survives the
quiesce and reset paths, such as MTU changes, down/up and ring resizes.
It also rejects MTU changes above VMXNET3_XDP_MAX_MTU while XDP is
attached.
> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
> index fb98eb7712584..e84bf116a3baf 100644
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> @@ -2104,7 +2104,6 @@ vmxnet3_rq_cleanup_all(struct vmxnet3_adapter *adapter)
>
> for (i = 0; i < adapter->num_rx_queues; i++)
> vmxnet3_rq_cleanup(&adapter->rx_queue[i], adapter);
> - rcu_assign_pointer(adapter->xdp_bpf_prog, NULL);
> }
[Severity: Critical]
If an XDP attach fails inside vmxnet3_xdp_set(), does removing this line
leave a dangling program pointer in adapter->xdp_bpf_prog?
vmxnet3_xdp_set() publishes the new program and drops the old one before
it rebuilds and reactivates the device:
drivers/net/vmxnet3/vmxnet3_xdp.c:vmxnet3_xdp_set() {
...
vmxnet3_xdp_exchange_program(adapter, new_bpf_prog);
if (old_bpf_prog)
bpf_prog_put(old_bpf_prog);
...
err = vmxnet3_activate_dev(adapter);
if (err) {
NL_SET_ERR_MSG_MOD(extack,
"failed to activate device for XDP.");
return -EOPNOTSUPP;
}
...
}
When ndo_bpf fails, dev_xdp_install() in net/core/dev.c drops the
reference it took for the driver. It also does not record the program:
err = bpf_op(dev, &xdp);
if (err) {
if (prog)
bpf_prog_put(prog);
return err;
}
Before this patch, every error label in vmxnet3_activate_dev()
(activate_err, irq_err, rq_err) went through vmxnet3_rq_cleanup_all().
As a side effect, that reset adapter->xdp_bpf_prog to NULL. With the line
removed, nothing clears the pointer on that path.
vmxnet3_activate_dev() can fail in three ways:
- vmxnet3_rq_init_all() returns -ENOMEM because vmxnet3_create_pp() or
vmxnet3_rq_alloc_rx_buf() failed.
- vmxnet3_request_irqs() fails.
- The device rejects VMXNET3_CMD_ACTIVATE_DEV.
The vmxnet3_rq_create_all() error return in vmxnet3_xdp_set() leaves the
pointer in the same state.
Take an attach of program P on a running interface (old NULL, new P).
After this failure, adapter->xdp_bpf_prog == P, but neither the driver
nor the core holds a reference to P. Once userspace closes the prog fd,
P and its JIT image are freed.
vmxnet3_xdp_enabled() still returns true, so on the next down/up the rx
rings are rebuilt in XDP mode:
vmxnet3_open()
vmxnet3_activate_dev()
vmxnet3_rq_init_all()
vmxnet3_rq_init()
buf_type = VMXNET3_RX_BUF_XDP
Received packets then go from vmxnet3_rq_rx_complete() into
vmxnet3_process_xdp() or vmxnet3_process_xdp_small(), which do:
xdp_prog = rcu_dereference(rq->adapter->xdp_bpf_prog);
Could this run the freed program on every received packet?
A later attach of another program would see old_bpf_prog == P and call
bpf_prog_put() on the freed program. dev_xdp_uninstall() only calls
ndo_bpf for modes the core has recorded, so unregister would not clear
the stale pointer either.
The detach case (old P, new NULL) can still end up in the same state.
The same failure leaves the driver with NULL after P has already been
put, while the core still reports P as attached. That is the core/driver
disagreement the commit message describes.
The commit message says:
"The program is exchanged and released by vmxnet3_xdp_set()"
The error paths in vmxnet3_xdp_set() do not roll back the exchange,
though. Would it be safer to publish the new program and put the old one
only after vmxnet3_activate_dev() succeeds? Another option would be to
restore old_bpf_prog on the error paths without dropping its reference.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122002847.616-1-filzador%40gmail.com
prev parent reply other threads:[~2026-11-23 1:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 0:28 [PATCH net 0/2] vmxnet3: fix native XDP crash on oversized frames and XDP loss on reset Philipp Sudakas
2026-11-22 0:28 ` [PATCH net 1/2] vmxnet3: drop XDP frames that do not fit in one rx buffer Philipp Sudakas
2026-11-23 1:06 ` netdev-bot+sashiko
2026-11-22 0:28 ` [PATCH net 2/2] vmxnet3: keep the XDP program across device resets Philipp Sudakas
2026-11-23 1:06 ` netdev-bot+sashiko [this message]
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=179539597786.3135.350150131775018719@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=filzador@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ronak.doshi@broadcom.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