From: Philipp Sudakas <filzador@gmail.com>
To: ronak.doshi@broadcom.com, bcm-kernel-feedback-list@broadcom.com
Cc: 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,
Philipp Sudakas <filzador@gmail.com>
Subject: [PATCH net v2 3/5] vmxnet3: limit the XDP MTU to the rx head buffer size
Date: Mon, 23 Nov 2026 15:48:53 +0300 [thread overview]
Message-ID: <20261123124855.1021-4-filzador@gmail.com> (raw)
In-Reply-To: <20261123124855.1021-1-filzador@gmail.com>
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
next prev parent reply other threads:[~2026-11-23 12:49 UTC|newest]
Thread overview: 6+ 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-23 12:48 ` Philipp Sudakas [this message]
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
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=20261123124855.1021-4-filzador@gmail.com \
--to=filzador@gmail.com \
--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=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