* [PATCH net v2 0/5] vmxnet3: fix native XDP crash on oversized frames and XDP loss on reset
@ 2026-11-23 12:48 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
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Philipp Sudakas @ 2026-11-23 12:48 UTC (permalink / raw)
To: ronak.doshi, bcm-kernel-feedback-list
Cc: netdev, bpf, andrew+netdev, davem, edumazet, kuba, pabeni, ast,
daniel, hawk, john.fastabend, sdf, u9012063, Philipp Sudakas
Fixes for native XDP on vmxnet3. A single frame from any host on the
same L2 segment can crash a guest that has an XDP program attached;
any device reset silently stops XDP; and the attach error path leaves
the driver with a program it holds no reference to.
Patch 1: the rx data ring XDP path leaves rx_ctx.skb pointing at the
ring head page after a non-PASS verdict. Patch 4 relies on rx_ctx.skb
being NULL between frames.
Patch 2: vmxnet3_xdp_set() releases the old program before the device
is active again and does not roll back on failure. Keep the old
program on failure. Patch 5 removes the side effect that used to hide
this.
Patch 3: with an MTU between 3051 and VMXNET3_XDP_MAX_MTU, full-sized
frames do not fit the 3072-byte rx head buffer. Limit the XDP MTU so
that they do.
Patch 4: a frame that does not fit in one XDP rx buffer (sop without
eop) reaches the skb path, which takes the page_pool page for an skb:
kernel BUG in skb_put(). With MTU 1500, a single untagged frame of
1523..1526 bytes is enough. Drop such frames.
Patch 5: vmxnet3_rq_cleanup_all() clears xdp_bpf_prog on every quiesce
(MTU change, down/up, ring resize, reset). XDP stops being called while
the program is still reported as attached, and its reference leaks.
Reproduced with stock modules on Debian kernels 6.12.113, 6.12.117 and
7.2.12 (7.2.12 untainted), VMware virtual hardware version 20. A small
reproducer (raw frame sender and an XDP_PASS counter program) is
available on request.
Testing:
- Run-tested: the patched vmxnet3 files of net as of today, with the
driver's current vmxnet3_ethtool.c and headers, built as a module for
a Debian 7.2.12 kernel; VMware virtual hardware version 20, MTU 1500,
native XDP:
- untagged frames of 1514..1522 bytes reach XDP; 1523, 1524 and
1526 bytes are dropped and counted in drop_total; 1530 bytes with
a VLAN 0 tag are dropped; no crash;
- 5000 frames of 1500 bytes mixed with 5000 of 1524 bytes: exactly
5000 XDP passes and 5000 drops;
- with XDP_DROP attached, small frames over the rx data ring
(64 and 100 bytes) are dropped by XDP, followed by normal and
oversized frames without issue;
- after an MTU change, down/up and an rx ring resize the same
program keeps running; after detach no program is left loaded;
- MTU 3051 is refused with XDP attached and attaching at MTU 3051
is refused; at MTU 3050 frames of 3064 bytes reach XDP and 3073
bytes are dropped;
- attach and detach failures were forced with a test-only module
parameter that skips vmxnet3_rq_create_all() and returns -ENOMEM:
after a failed attach no XDP program is attached or left loaded,
and after down/up the stack receives again; after a failed detach
the old program stays attached and runs again after down/up, and
is freed after a later detach.
No warnings in dmesg.
- Not covered: the rx_error paths (no way to make the virtual device
report a receive error), and VLAN tags other than 0, which the test
switch does not pass.
Changes in v2:
- New patch 1, and the rx_error double count fix in patch 4, after an
automated review of v1 (Sashiko).
- New patch 2: v1 patch 2 made the attach failure path in
vmxnet3_xdp_set() reachable with a stale program pointer.
- New patch 3: v1 left the MTU 3051..VMXNET3_XDP_MAX_MTU range as a
known limit; it is now refused.
- Patch 4 no longer counts the dropped frame against the NAPI budget:
in mainline other non-PASS XDP verdicts are not counted either, so
the v1 comment claiming so was wrong.
- Patch 4: fixed a line over 80 columns.
- Cc the networking, XDP and BPF maintainers and the author of the
blamed commit, as get_maintainer.pl lists them.
- v1: https://lore.kernel.org/netdev/20261122002847.616-1-filzador@gmail.com/
The problems were found and analysed, and the patches drafted, with
the help of an AI coding assistant; reproduction and testing were run
on the reporter's lab systems.
Philipp Sudakas (5):
vmxnet3: clear rx_ctx.skb after a data ring XDP verdict
vmxnet3: keep the previous XDP program when attaching fails
vmxnet3: limit the XDP MTU to the rx head buffer size
vmxnet3: drop XDP frames that do not fit in one rx buffer
vmxnet3: keep the XDP program across device resets
drivers/net/vmxnet3/vmxnet3_drv.c | 27 +++++++++++++++++++++++++--
drivers/net/vmxnet3/vmxnet3_xdp.c | 22 +++++++++++++++++-----
drivers/net/vmxnet3/vmxnet3_xdp.h | 10 ++++++++--
3 files changed, 50 insertions(+), 9 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v2 1/5] vmxnet3: clear rx_ctx.skb after a data ring XDP verdict
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 ` Philipp Sudakas
2026-11-23 12:48 ` [PATCH net v2 2/5] vmxnet3: keep the previous XDP program when attaching fails Philipp Sudakas
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Philipp Sudakas @ 2026-11-23 12:48 UTC (permalink / raw)
To: ronak.doshi, bcm-kernel-feedback-list
Cc: netdev, bpf, andrew+netdev, davem, edumazet, kuba, pabeni, ast,
daniel, hawk, john.fastabend, sdf, u9012063, Philipp Sudakas
For a completion from the rx data ring, vmxnet3_rq_rx_complete() sets
ctx->skb = rbi->skb in the sop block before running XDP on the data
ring copy. With XDP enabled, the ring 0 head buffer is
VMXNET3_RX_BUF_XDP and that union member holds a page_pool page, not
an skb. On XDP_PASS ctx->skb is replaced with the new skb, but on any
other verdict, XDP_DROP included, it keeps the page pointer.
The stale value then belongs to no frame. If the next completion is a
single descriptor with rcd->err set, vmxnet3_rx_error() passes it to
dev_kfree_skb_irq(). The ring buffer XDP path already clears ctx->skb
after a non-PASS verdict; do the same here.
The problem was found and analysed, and this patch drafted, with the
help of an AI coding assistant. It was reported by an automated
review of an earlier version of this series.
Fixes: 54f00cce1178 ("vmxnet3: Add XDP support.")
Signed-off-by: Philipp Sudakas <filzador@gmail.com>
---
drivers/net/vmxnet3/vmxnet3_drv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index f8df83f..e8be95c 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1742,6 +1742,7 @@ skip_xdp:
ctx->skb = skb_xdp_pass;
goto sop_done;
}
+ ctx->skb = NULL;
need_flush |= act == XDP_REDIRECT;
goto rcd_done;
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v2 2/5] vmxnet3: keep the previous XDP program when attaching fails
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 ` Philipp Sudakas
2026-11-24 13:26 ` netdev-bot+sashiko
2026-11-23 12:48 ` [PATCH net v2 3/5] vmxnet3: limit the XDP MTU to the rx head buffer size Philipp Sudakas
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Philipp Sudakas @ 2026-11-23 12:48 UTC (permalink / raw)
To: ronak.doshi, bcm-kernel-feedback-list
Cc: netdev, bpf, andrew+netdev, davem, edumazet, kuba, pabeni, ast,
daniel, hawk, john.fastabend, sdf, u9012063, Philipp Sudakas
vmxnet3_xdp_set() publishes the new program and drops its reference to
the old one before it recreates the rx queues and reactivates the
device. If vmxnet3_rq_create_all() or vmxnet3_activate_dev() then
fails, it returns an error without rolling back. dev_xdp_install()
treats the error as "nothing changed": it drops the reference it took
for the new program and keeps the old program recorded as attached.
The driver is then left with the new program, to which it holds no
reference, and without the reference to the old program, which the
core still considers attached. So far this was mostly hidden because
every error path of vmxnet3_activate_dev() goes through
vmxnet3_rq_cleanup_all(), which also clears xdp_bpf_prog.
Release the old program only after the device is active again, and on
failure restore it, together with the redirect target feature.
The problem was found and analysed, and this patch drafted, with the
help of an AI coding assistant. It was also reported by an automated
review of an earlier version of this series.
Fixes: 54f00cce1178 ("vmxnet3: Add XDP support.")
Signed-off-by: Philipp Sudakas <filzador@gmail.com>
---
drivers/net/vmxnet3/vmxnet3_xdp.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_xdp.c b/drivers/net/vmxnet3/vmxnet3_xdp.c
index 5f47049..45259b2 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);
+ if (old_bpf_prog)
+ xdp_features_set_redirect_target(netdev, false);
+ else
+ xdp_features_clear_redirect_target(netdev);
+ return -EOPNOTSUPP;
}
/* This is the main xdp call used by kernel to set/unset eBPF program. */
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v2 3/5] vmxnet3: limit the XDP MTU to the rx head buffer size
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-23 12:48 ` 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-23 12:48 ` [PATCH net v2 5/5] vmxnet3: keep the XDP program across device resets Philipp Sudakas
4 siblings, 0 replies; 8+ messages in thread
From: Philipp Sudakas @ 2026-11-23 12:48 UTC (permalink / raw)
To: ronak.doshi, bcm-kernel-feedback-list
Cc: netdev, bpf, andrew+netdev, davem, edumazet, kuba, pabeni, ast,
daniel, hawk, john.fastabend, sdf, u9012063, Philipp Sudakas
With XDP, rx ring 0 head buffers are page_pool pages, but the length
given to the device is skb_buf_size, which vmxnet3_adjust_rx_ring_size()
caps at VMXNET3_MAX_SKB_BUF_SIZE (3072). VMXNET3_XDP_MAX_MTU only
accounts for the page size, about 3494 on x86_64 with 4K pages.
With an MTU between 3051 and VMXNET3_XDP_MAX_MTU, a full-sized frame
does not fit the head buffer and the device splits it over a head and
a body descriptor. Such completions take the skb path with a page in
rbi->skb, which crashes the guest; see the next patch for the details.
Cap VMXNET3_XDP_MAX_MTU at VMXNET3_MAX_SKB_BUF_SIZE -
VMXNET3_MAX_ETH_HDR_SIZE, so that up to that MTU skb_buf_size is
MTU + VMXNET3_MAX_ETH_HDR_SIZE and a frame of MTU plus Ethernet and
VLAN headers fits the head buffer.
The problem was found and analysed, and this patch drafted, with the
help of an AI coding assistant. It was reported by an automated review
of an earlier version of this series.
Fixes: 54f00cce1178 ("vmxnet3: Add XDP support.")
Signed-off-by: Philipp Sudakas <filzador@gmail.com>
---
drivers/net/vmxnet3/vmxnet3_xdp.h | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_xdp.h b/drivers/net/vmxnet3/vmxnet3_xdp.h
index f9d843e..6fd8a4e 100644
--- a/drivers/net/vmxnet3/vmxnet3_xdp.h
+++ b/drivers/net/vmxnet3/vmxnet3_xdp.h
@@ -20,8 +20,14 @@
#define VMXNET3_XDP_RX_OFFSET VMXNET3_XDP_HEADROOM
#define VMXNET3_XDP_MAX_FRSIZE (PAGE_SIZE - VMXNET3_XDP_HEADROOM - \
VMXNET3_XDP_RX_TAILROOM)
-#define VMXNET3_XDP_MAX_MTU (VMXNET3_XDP_MAX_FRSIZE - ETH_HLEN - \
- 2 * VLAN_HLEN - ETH_FCS_LEN)
+/* A frame must also fit the rx head buffer, at most
+ * VMXNET3_MAX_SKB_BUF_SIZE bytes (see vmxnet3_adjust_rx_ring_size()).
+ */
+#define VMXNET3_XDP_MAX_MTU min_t(unsigned int, \
+ VMXNET3_XDP_MAX_FRSIZE - ETH_HLEN - \
+ 2 * VLAN_HLEN - ETH_FCS_LEN, \
+ VMXNET3_MAX_SKB_BUF_SIZE - \
+ VMXNET3_MAX_ETH_HDR_SIZE)
int vmxnet3_xdp(struct net_device *netdev, struct netdev_bpf *bpf);
int vmxnet3_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v2 4/5] vmxnet3: drop XDP frames that do not fit in one rx buffer
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
` (2 preceding siblings ...)
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 ` 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
4 siblings, 1 reply; 8+ messages in thread
From: Philipp Sudakas @ 2026-11-23 12:48 UTC (permalink / raw)
To: ronak.doshi, bcm-kernel-feedback-list
Cc: netdev, bpf, andrew+netdev, davem, edumazet, kuba, pabeni, ast,
daniel, hawk, john.fastabend, sdf, u9012063, Philipp Sudakas
With XDP enabled, rx ring 0 head buffers are page_pool pages and the
device is given a buffer length of MTU + 22 (skb_buf_size; the previous
patch keeps the XDP MTU low enough for that). The device still accepts
somewhat longer frames (observed: up to MTU + 26 untagged, MTU + 30
with a VLAN tag) and splits them over a head and a body descriptor.
vmxnet3_rq_rx_complete() runs XDP only for completions with both sop
and eop set. A frame with sop but without eop falls through to the skb
path, which uses rbi->skb although, for a VMXNET3_RX_BUF_XDP buffer,
that union member holds the page. The result is a kernel BUG in
skb_put(), or at BUG_ON(ctx->skb != NULL || rbi->skb == NULL):
kernel BUG at net/core/skbuff.c:2637!
RIP: 0010:skb_put+0x3c/0x40
Call Trace:
<IRQ>
vmxnet3_rq_rx_complete+0x893/0x12b0 [vmxnet3]
vmxnet3_poll_rx_only+0x38/0xd0 [vmxnet3]
__napi_poll+0x2b/0x160
net_rx_action+0x336/0x420
One frame of MTU + 23 to MTU + 26 bytes from any host on the same L2
segment is enough to crash a guest that has a native XDP program
attached to a vmxnet3 interface.
XDP on vmxnet3 is single-buffer, so drop such frames: count them in
drop_total, reuse the head buffer and skip the body buffers, as the
existing allocation failure path does. The completions of one frame
may span two polls, so start each poll with skip_page_frags set when
no frame is in progress (rx_ctx.skb == NULL; the first patch of this
series makes that hold for the data ring path too): a body buffer
without a head can only belong to a dropped frame. If the last body
buffer of a dropped frame has rcd->err set, do not count the frame a
second time in vmxnet3_rx_error().
The problem was found and analysed, and this patch drafted, with the
help of an AI coding assistant. It was reproduced and tested on the
reporter's lab systems as described in the cover letter.
Fixes: 54f00cce1178 ("vmxnet3: Add XDP support.")
Signed-off-by: Philipp Sudakas <filzador@gmail.com>
---
drivers/net/vmxnet3/vmxnet3_drv.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index e8be95c..66f6773 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -1614,7 +1614,8 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
adapter->rx_prod_offset, adapter->rx_prod2_offset
};
u32 num_pkts = 0;
- bool skip_page_frags = false;
+ /* A frame dropped at its head may continue in the next poll. */
+ bool skip_page_frags = !rq->rx_ctx.skb;
bool encap_lro = false;
struct Vmxnet3_RxCompDesc *rcd;
struct vmxnet3_rx_ctx *ctx = &rq->rx_ctx;
@@ -1662,10 +1663,27 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
rxd->len != rbi->len);
if (unlikely(rcd->eop && rcd->err)) {
+ /* The last body buffer of a frame already dropped */
+ if (!rcd->sop && skip_page_frags)
+ goto rcd_done;
vmxnet3_rx_error(rq, rcd, ctx, adapter);
goto rcd_done;
}
+ if (rcd->sop && !rcd->eop &&
+ rbi->buf_type == VMXNET3_RX_BUF_XDP &&
+ !VMXNET3_RX_DATA_RING(adapter, rcd->rqID)) {
+ /* The frame did not fit one XDP buffer. XDP here is
+ * single-buffer and the head holds a page, not an
+ * skb: drop the frame, reuse the head buffer and
+ * skip the body buffers.
+ */
+ rq->stats.drop_total++;
+ ctx->skb = NULL;
+ skip_page_frags = true;
+ goto rcd_done;
+ }
+
if (rcd->sop && rcd->eop && vmxnet3_xdp_enabled(adapter)) {
struct sk_buff *skb_xdp_pass;
int act;
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net v2 5/5] vmxnet3: keep the XDP program across device resets
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
` (3 preceding siblings ...)
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-23 12:48 ` Philipp Sudakas
4 siblings, 0 replies; 8+ messages in thread
From: Philipp Sudakas @ 2026-11-23 12:48 UTC (permalink / raw)
To: ronak.doshi, bcm-kernel-feedback-list
Cc: netdev, bpf, andrew+netdev, davem, edumazet, kuba, pabeni, ast,
daniel, hawk, john.fastabend, sdf, u9012063, Philipp Sudakas
vmxnet3_rq_cleanup_all() clears adapter->xdp_bpf_prog. It is called
from vmxnet3_quiesce_dev(), so on every MTU change, down/up, ring
resize, reset work and resume. After that the driver no longer runs
XDP, while the core still reports the program as attached, and the
driver's reference to the program is never dropped: a later detach
finds xdp_bpf_prog already NULL and returns early.
Seen on 6.12.117 and 7.2.12: after "ip link set dev X mtu 1400",
"ip link set dev X down; ip link set dev X up" or
"ethtool -G X rx 512", the attached program is no longer called, and
each detached program stays loaded.
Do not clear the pointer there. The program is exchanged and released
by vmxnet3_xdp_set(), which also runs when the device is unregistered,
and which since an earlier patch of this series keeps the previous
program on failure. Rx rings are then recreated in XDP mode after a
reset, as vmxnet3_xdp_enabled() stays true.
Since the program now survives an MTU change, reject an MTU above
VMXNET3_XDP_MAX_MTU while XDP is attached, as vmxnet3_xdp_set()
already refuses to attach a program at such an MTU.
The problem was found and analysed, and this patch drafted, with the
help of an AI coding assistant. It was reproduced and tested on the
reporter's lab systems as described in the cover letter.
Fixes: 54f00cce1178 ("vmxnet3: Add XDP support.")
Signed-off-by: Philipp Sudakas <filzador@gmail.com>
---
drivers/net/vmxnet3/vmxnet3_drv.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 66f6773..22367b8 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2107,7 +2107,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);
}
@@ -3666,6 +3665,11 @@ vmxnet3_change_mtu(struct net_device *netdev, int new_mtu)
struct vmxnet3_adapter *adapter = netdev_priv(netdev);
int err = 0;
+ if (vmxnet3_xdp_enabled(adapter) && new_mtu > VMXNET3_XDP_MAX_MTU) {
+ netdev_err(netdev, "MTU %d too large for XDP\n", new_mtu);
+ return -EINVAL;
+ }
+
/*
* Reset_work may be in the middle of resetting the device, wait for its
* completion.
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 2/5] vmxnet3: keep the previous XDP program when attaching fails
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
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 13:26 UTC (permalink / raw)
To: filzador
Cc: ronak.doshi, bcm-kernel-feedback-list, netdev, bpf, andrew+netdev,
davem, edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend,
sdf, u9012063
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v2 4/5] vmxnet3: drop XDP frames that do not fit in one rx buffer
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
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 13:26 UTC (permalink / raw)
To: filzador
Cc: ronak.doshi, bcm-kernel-feedback-list, netdev, bpf, andrew+netdev,
davem, edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend,
sdf, u9012063
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In vmxnet3_rq_rx_complete() (drivers/net/vmxnet3/vmxnet3_drv.c),
the patch adds an early exit inside the `rcd->eop && rcd->err` branch:…
- [Low] The patch changes the initialiser in vmxnet3_rq_rx_complete()
(drivers/net/vmxnet3/vmxnet3_drv.c:1618) from `bool skip_page_frags =…
--
vmxnet3: drop XDP frames that do not fit in one rx buffer
With XDP enabled, a frame with sop set but not eop can land in a page_pool
head buffer. It then falls through to the skb path and crashes. This patch
drops such frames and skips their body buffers. It also starts each poll
with skip_page_frags set when no frame is in progress, and avoids counting
a dropped frame twice when its last body buffer has rcd->err set.
> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
> index e8be95c1d9f8e..66f677391bbbc 100644
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> @@ -1614,7 +1614,8 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
> adapter->rx_prod_offset, adapter->rx_prod2_offset
> };
> u32 num_pkts = 0;
> - bool skip_page_frags = false;
> + /* A frame dropped at its head may continue in the next poll. */
> + bool skip_page_frags = !rq->rx_ctx.skb;
[Severity: Low]
This initializer runs on every poll in vmxnet3_rq_rx_complete(), with or
without XDP. Does it also change behaviour on the non-XDP rx path?
Before this patch, two head-buffer drops set only the poll-local
skip_page_frags: the netdev_alloc_skb_ip_align() failure and the
dma_map_single() failure.
Suppose the poll ended before the body completion became visible. The next
poll then started with skip_page_frags = false and ctx->skb == NULL, and the
body completion would hit this in the non-sop branch:
BUG_ON(ctx->skb == NULL && !skip_page_frags);
That problem seems to predate 54f00cce1178. With this change the non-XDP
case is fixed as well. Orphan body completions at the start of a poll are
now skipped silently instead of triggering the BUG_ON.
The subject, the Fixes: tag and this sentence in the commit message all
present the change as XDP-only:
"drop such frames: count them in drop_total, reuse the head buffer and
skip the body buffers, as the existing allocation failure path does."
Could the commit message say that the existing allocation failure path had
the same cross-poll problem, and that non-XDP rx behaviour changes too? The
non-XDP issue looks older than the Fixes: commit, so this would help
stable backport triage.
[ ... ]
> @@ -1662,10 +1663,27 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
> rxd->len != rbi->len);
>
> if (unlikely(rcd->eop && rcd->err)) {
> + /* The last body buffer of a frame already dropped */
> + if (!rcd->sop && skip_page_frags)
> + goto rcd_done;
[Severity: Low]
Does this skip assume that every path setting skip_page_frags has already
counted the frame in drop_total?
The head-buffer drops do increment drop_total. Those are the new XDP
oversize drop, the netdev_alloc_skb_ip_align() failure and the
dma_map_single() failure.
The two body-buffer drops later in vmxnet3_rq_rx_complete() set
skip_page_frags without touching drop_total:
if (unlikely(!new_page)) {
rq->stats.rx_buf_alloc_failure++;
dev_kfree_skb(ctx->skb);
ctx->skb = NULL;
skip_page_frags = true;
goto rcd_done;
}
The dma_map_page() failure branch right after it does the same.
Before this patch, suppose the final body completion of such a frame had
rcd->eop && rcd->err set. vmxnet3_rx_error() then counted the frame once in
drop_err and drop_total.
With this check, does that frame go uncounted in both? drop_total feeds
rx_dropped in vmxnet3_get_stats64() and the ethtool drop counters.
Would it make sense to increment drop_total in those two body-path failure
branches? Another option is to limit this skip to drops that were already
counted.
> vmxnet3_rx_error(rq, rcd, ctx, adapter);
> goto rcd_done;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123124855.1021-1-filzador%40gmail.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-24 13:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox