Netdev List
 help / color / mirror / Atom feed
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 1/2] vmxnet3: drop XDP frames that do not fit in one rx buffer
Date: Mon, 23 Nov 2026 01:06:17 +0000	[thread overview]
Message-ID: <179539597704.3135.16978504109818344145@kernel.org> (raw)
In-Reply-To: <20261122002847.616-2-filzador@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 1 · Low: 2

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).

- [Medium] The commit message says the XDP head buffer given to the
  device is MTU + 22 (skb_buf_size).
- [Low] In vmxnet3_rq_rx_complete() (drivers/net/vmxnet3/vmxnet3_drv.c),
  the new comment says "Count it against the budget like other XDP…
- [Low] A frame dropped by the new head-drop branch in
  vmxnet3_rq_rx_complete() is counted twice in rq->stats.drop_total if…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch's
  new poll-start logic relies on the invariant it breaks, and it can…

--

vmxnet3: drop XDP frames that do not fit in one rx buffer

With XDP enabled, a frame the device splits over a head and a body
descriptor used to reach the skb path in vmxnet3_rq_rx_complete(). That
path treated the page_pool page as an skb and crashed the guest. This
patch drops such frames at the head, skips their body buffers, and
starts each poll with skip_page_frags set when no frame is in progress.

> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
> index f8df83f9965db..fb98eb7712584 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: High]
This is a pre-existing issue and was not introduced by this patch.
However, this new line assumes rq->rx_ctx.skb is NULL whenever no frame
is in progress, and the data ring XDP path can break that.

For a data ring completion with XDP enabled, VMXNET3_GET_RING_IDX()
returns 0, so rbi points into rq->buf_info[0]. vmxnet3_rq_init() marked
that entry VMXNET3_RX_BUF_XDP, so its union holds a struct page pointer.
The sop block in vmxnet3_rq_rx_complete() still does:

			skip_page_frags = false;
			ctx->skb = rbi->skb;
    ...
			if (rxDataRingUsed && vmxnet3_xdp_enabled(adapter)) {
    ...
				if (act == XDP_PASS) {
					ctx->skb = skb_xdp_pass;
					goto sop_done;
				}
				need_flush |= act == XDP_REDIRECT;

				goto rcd_done;
			}

On any verdict other than XDP_PASS, ctx->skb keeps the page pointer.
That includes an XDP_DROP firewall program. The stale value can carry
over into later polls.

Suppose the next completion has eop and err set. Would
vmxnet3_rx_error() then run this on a ring-owned page_pool page?

	if (ctx->skb)
		dev_kfree_skb_irq(ctx->skb);

With this patch, the stale non-NULL value also makes the next poll start
with skip_page_frags = false. An orphan non-sop body could then get past
BUG_ON(ctx->skb == NULL && !skip_page_frags) and reach
vmxnet3_append_frag() with the page treated as an skb.

Would it make sense to clear ctx->skb before that goto rcd_done? The
ring buffer XDP path already does this. Another option is to not assign
ctx->skb = rbi->skb for VMXNET3_RX_BUF_XDP buffers.

>  	bool encap_lro = false;
>  	struct Vmxnet3_RxCompDesc *rcd;
>  	struct vmxnet3_rx_ctx *ctx = &rq->rx_ctx;
> @@ -1666,6 +1667,21 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
>  			goto rcd_done;
>  		}
>  
> +		if (rcd->sop && !rcd->eop &&
> +		    rbi->buf_type == VMXNET3_RX_BUF_XDP &&
> +		    !VMXNET3_RX_DATA_RING(adapter, rcd->rqID)) {

[Severity: Medium]
The commit message says:

  the device is given a buffer length of MTU + 22 (skb_buf_size)

Does that hold for larger MTUs? vmxnet3_adjust_rx_ring_size() caps
skb_buf_size at VMXNET3_MAX_SKB_BUF_SIZE (3072) on v7:

		adapter->skb_buf_size = min((int)adapter->netdev->mtu + VMXNET3_MAX_ETH_HDR_SIZE,
					    VMXNET3_MAX_SKB_BUF_SIZE);

Before v7 it sets skb_buf_size = VMXNET3_MAX_SKB_BUF_SIZE once the MTU is
above 3050. vmxnet3_rq_init() then uses that value as the length of the
VMXNET3_RX_BUF_XDP head buffers.

vmxnet3_xdp_set() only rejects netdev->mtu > VMXNET3_XDP_MAX_MTU, which
is about 3494 on x86_64.

Take XDP attached with an MTU of roughly 3059 to 3494. Won't every
full-sized frame (MTU + 14 > 3072) be split into a head and a body, and
then be dropped silently by this branch? That would drop all full-MTU
traffic on such an interface, not only the MTU + 23 to MTU + 26 frames
the commit message describes.

The later commit "vmxnet3: keep the XDP program across device resets"
adds an XDP check to vmxnet3_change_mtu(). It uses the same
VMXNET3_XDP_MAX_MTU bound, though, so this MTU range still seems to be
accepted.

Could XDP head buffers get a device length based on
VMXNET3_XDP_MAX_FRSIZE instead? Alternatively, could XDP be rejected when
MTU + VMXNET3_MAX_ETH_HDR_SIZE > skb_buf_size?

> +			/* 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, skip its body buffers.
> +			 * Count it against the budget like other XDP verdicts.
> +			 */
> +			rq->stats.drop_total++;

[Severity: Low]
Can a frame dropped here be counted twice in drop_total? Suppose its
eop body completion has rcd->err set. This check at the top of the loop
runs before the skip_page_frags handling:

		if (unlikely(rcd->eop && rcd->err)) {
			vmxnet3_rx_error(rq, rcd, ctx, adapter);
			goto rcd_done;
		}

vmxnet3_rx_error() then increments rq->stats.drop_total again, without
any condition. vmxnet3_get_stats64() reports drop_total as rx_dropped.

The skb allocation failure path already has the same double count, so
this adds a second case. Also, the comment in vmxnet3_rx_error() says
ctx->skb may be NULL only for the first and only desc of a packet. With
this patch, that no longer covers every case.

> +			ctx->skb = NULL;
> +			skip_page_frags = true;
> +			num_pkts++;

[Severity: Low]
Is the comment "Count it against the budget like other XDP verdicts"
accurate? After vmxnet3_process_xdp() returns a verdict other than
XDP_PASS, vmxnet3_rq_rx_complete() does:

			ctx->skb = NULL;
			need_flush |= act == XDP_REDIRECT;

			goto rcd_done;

and num_pkts is not incremented. The same goes for the data ring path
after vmxnet3_process_xdp_small(), and for the allocation failure drop
path that this branch says it copies. Only XDP_PASS is counted, later,
after sop_done.

That makes this the only drop path that uses up NAPI budget. Should the
comment and the commit message be adjusted, or should the accounting be
made consistent?

> +			goto rcd_done;
> +		}
> +

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122002847.616-1-filzador%40gmail.com

  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 [this message]
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

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=179539597704.3135.16978504109818344145@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