mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: amaan.cheval@gmail.com
Cc: netdev@vger.kernel.org, joshwash@google.com,
	hramamurthy@google.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, bcf@google.com, jordanrhee@google.com,
	przemyslaw.kitszel@intel.com, maciej.fijalkowski@intel.com,
	pkaligineedi@google.com, maolson@google.com, csully@google.com,
	willemb@google.com, yangchun@google.com, npl@google.com,
	awogbemila@google.com, shailend@google.com, nktgrg@google.com,
	maxyuan@google.com, bpf@vger.kernel.org,
	john.fastabend@gmail.com, hawk@kernel.org, sdf@fomichev.me,
	daniel@iogearbox.net, ast@kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net v5 1/2] gve: refuse XDP on queue formats without XDP support
Date: Wed, 11 Nov 2026 10:06:52 +0000	[thread overview]
Message-ID: <179439161258.2199510.10096207449822395421@kernel.org> (raw)
In-Reply-To: <20261109100437.331423-2-amaan.cheval@gmail.com>

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

Critical: 0 · High: 0 (1) · Medium: 1 · 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).

- [Medium] The commit message misstates which queue formats the new check
  affects.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
  extends it.

--

gve: refuse XDP on queue formats without XDP support

This patch adds a check to gve_verify_xdp_configuration() that refuses XDP
setup when dev->xdp_features lacks NETDEV_XDP_ACT_BASIC. It replaces the
queue format gate dropped by commit d8a8ca14c937. The aim is to keep XDP
off DQO-QPL, whose RX page accounting can free a page that is still
DMA-mapped and registered in the QPL.

> Refuse XDP setup in gve_verify_xdp_configuration() whenever the driver
> advertises no XDP features for the current queue format, which today
> means DQO-QPL.

[Severity: Medium]
Is "which today means DQO-QPL" accurate? gve_set_netdev_xdp_features() only
sets NETDEV_XDP_ACT_BASIC for GQI-QPL and DQO-RDA:

drivers/net/ethernet/google/gve/gve_main.c:gve_set_netdev_xdp_features() {
	if (priv->queue_format == GVE_GQI_QPL_FORMAT) {
		xdp_features = NETDEV_XDP_ACT_BASIC;
		...
	} else if (priv->queue_format == GVE_DQO_RDA_FORMAT) {
		xdp_features = NETDEV_XDP_ACT_BASIC;
		...
	} else {
		xdp_features = 0;
	}
	...
}

GQI-RDA also falls into the else branch. gve_adminq.c can still select
GVE_GQI_RDA_FORMAT from the GQI_RDA and GQI_RAW_ADDRESSING device options,
so the new check refuses GQI-RDA as well.

The check that d8a8ca14c937 removed (queue_format != GVE_GQI_QPL_FORMAT)
also refused GQI-RDA. Since that commit, XDP could be attached on GQI-RDA,
and XDP_TX there takes this path:

gve_rx()
  gve_xdp_done()
    gve_xdp_xmit_one()
      gve_tx_fill_xdp()

gve_tx_fill_xdp() always uses tx->tx_fifo: it calls gve_tx_alloc_fifo(),
memcpy()s into tx->tx_fifo.base and reads tx->tx_fifo.qpl->page_buses. A
raw-addressing TX ring never allocates that FIFO. Isn't that a NULL
dereference that this patch also fixes without saying so?

Could the commit message mention GQI-RDA? Two things are worth stating:
GQI-RDA now gets -EOPNOTSUPP, and this closes the XDP_TX crash there. That
would help stable backporters.

The follow-up patch "gve: fix RX page refcount overflow from INT_MAX
pagecnt_bias" uses the same wording ("The previous patch keeps it that way
by blocking XDP on DQO-QPL"). Its safety argument also depends on XDP being
blocked on GQI-RDA.

> diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
> index 2437cd8ba6331..fe560f5c5408c 100644
> --- a/drivers/net/ethernet/google/gve/gve_main.c
> +++ b/drivers/net/ethernet/google/gve/gve_main.c
> @@ -1723,6 +1723,12 @@ static int gve_verify_xdp_configuration(struct net_device *dev,
>  	struct gve_priv *priv = netdev_priv(dev);
>  	u16 max_xdp_mtu;
>  
> +	if (!(dev->xdp_features & NETDEV_XDP_ACT_BASIC)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "XDP is not supported on this queue format.");
> +		return -EOPNOTSUPP;
> +	}
> +

[Severity: High]
This is a pre-existing issue that this patch did not introduce, but the
patch adds another exit to the same gate. gve_xdp() calls
gve_verify_xdp_configuration() before it looks at the command, so the gate
also runs for teardown:

drivers/net/ethernet/google/gve/gve_main.c:gve_xdp() {
	err = gve_verify_xdp_configuration(dev, xdp->extack);
	if (err)
		return err;
	switch (xdp->command) {
	case XDP_SETUP_PROG:
		return gve_set_xdp(priv, xdp->prog, xdp->extack);
	case XDP_SETUP_XSK_POOL:
		if (xdp->xsk.pool)
			...
		else
			return gve_xsk_pool_disable(dev, xdp->xsk.queue_id);
	...
}

Several of the gate's conditions can become true after a successful bind:

- gve has no ndo_change_mtu, so the MTU can be raised above max_xdp_mtu
  while a zero-copy pool is bound.
- gve_set_features() refuses HW-GRO only when priv->xdp_prog is set, so
  HW-GRO can be turned on while only a pool is bound.
- The queue counts can be changed the same way.

When the AF_XDP socket is then closed:

xp_release_deferred()
  xp_clear_dev()
    __xp_clear_dev()
      xp_disable_drv_zc()
        gve_xdp()
          gve_verify_xdp_configuration()   /* returns -EOPNOTSUPP */

On failure, xp_disable_drv_zc() only does WARN(1, "Failed to disable
zero-copy!\n"). The core then goes on to xsk_clear_pool_at_qid(),
xdp_put_umem() and xp_destroy().

Because gve_xsk_pool_disable() never runs, clear_bit(qid, priv->xsk_pools),
xsk_pool_dma_unmap() and gve_unreg_xsk_pool() are all skipped. Won't
rx->xsk_pool and tx->xsk_pool still point at the freed pool when the RX
refill and XSK TX NAPI paths use them? The UMEM DMA mappings would also be
leaked.

dev_xdp_uninstall() follows the same pattern for programs. It does WARN_ON()
on the failed removal and then calls bpf_prog_put(), which leaves
priv->xdp_prog dangling.

The new xdp_features check cannot change between setup and teardown by
itself, since gve_setup_device() computes it only from queue_format. Even
so, would it be better to run the verification only for XDP_SETUP_PROG with
a non-NULL prog and for pool enable, so that teardown is never refused?

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

  parent reply	other threads:[~2026-11-11 10:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 10:04 [PATCH net v5 0/2] gve: fix RX page refcount overflow with the pagecnt bias Amaan Cheval
2026-11-09 10:04 ` [PATCH net v5 1/2] gve: refuse XDP on queue formats without XDP support Amaan Cheval
2026-11-09 19:45   ` Joshua Washington
2026-11-11 10:06   ` netdev-bot+sashiko [this message]
2026-11-09 10:04 ` [PATCH net v5 2/2] gve: fix RX page refcount overflow from INT_MAX pagecnt_bias Amaan Cheval

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=179439161258.2199510.10096207449822395421@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=amaan.cheval@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=awogbemila@google.com \
    --cc=bcf@google.com \
    --cc=bpf@vger.kernel.org \
    --cc=csully@google.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hawk@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=maolson@google.com \
    --cc=maxyuan@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=npl@google.com \
    --cc=pabeni@redhat.com \
    --cc=pkaligineedi@google.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sdf@fomichev.me \
    --cc=shailend@google.com \
    --cc=stable@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=yangchun@google.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

all inboxes | Powered by JetHome®