All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Harshitha Ramamurthy" <hramamurthy@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 08/15] gve: refactor gve_init_priv for reset path
Date: Wed, 03 Jun 2026 23:59:27 +0000	[thread overview]
Message-ID: <20260603235928.0B9D81F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602235900.3050782-9-hramamurthy@google.com>

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

New issues:
- [High] gve_reset_recovery error path leaves device in a state where subsequent ndo_open causes Use-After-Free and NULL pointer dereferences.

Pre-existing issues:
- [High] Device reset leaks XSK pool DMA mappings and silently breaks XDP sockets.
--

commit b96244d58e5385fb7dc71f1bd8136017d84f17d7
Author: Harshitha Ramamurthy <hramamurthy@google.com>

gve: refactor gve_init_priv for reset path

This commit refactors gve_init_priv() into targeted setup functions to bypass
full initialization during the reset path. It moves admin queue allocation and
device properties negotiation into gve_probe(). This prepares the driver for
adding mailbox mode control plane initialization in upcoming patches.

> diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
> index d693caed7e3d1..746ff69a28ddc 100644
> --- a/drivers/net/ethernet/google/gve/gve_main.c
> +++ b/drivers/net/ethernet/google/gve/gve_main.c
> @@ -2414,6 +2416,33 @@ static void gve_set_buf_sizes(struct gve_priv *priv)
>  		priv->header_buf_size = device_info->header_buf_size;
>  }
>  
> +static int gve_setup_device(struct gve_priv *priv)
> +{
> +	int err;
> +
> +	priv->xsk_pools = bitmap_zalloc(priv->rx_cfg.max_queues, GFP_KERNEL);

[Severity: High]
This is a pre-existing issue, but does this allocation cause an XDP socket
DMA mapping leak and silently break XDP sockets during a device reset?

When a device reset occurs, such as from a transmit timeout, the teardown
process frees the priv->xsk_pools bitmap without unmapping the active XDP
socket DMA mappings.

Then gve_reset_recovery() calls gve_setup_device() here, which allocates a
fresh, zeroed xsk_pools bitmap. When the interface is brought back up, the
driver reads the zeroed bitmap, forgetting which queues had active XSK pools.
This causes XDP sockets to silently stop receiving traffic and permanently
leaks the DMA mappings established by gve_xsk_pool_enable().

> +	if (!priv->xsk_pools) {
> +		err = -ENOMEM;
> +		goto err;
> +	}

[ ... ]

> @@ -2554,15 +2540,29 @@ static int gve_reset_recovery(struct gve_priv *priv, bool was_up)
>  {
>  	int err;
>  
> -	err = gve_init_priv(priv, true);
> -	if (err)
> +	err = gve_adminq_init(priv);
> +	if (err) {
> +		dev_err(&priv->pdev->dev,
> +			"Failed to alloc admin queue: err=%d\n", err);
>  		goto err;
> +	}
> +
> +	err = gve_setup_device(priv);
> +	if (err)
> +		goto err_free_adminq;
>  	if (was_up) {
>  		err = gve_open(priv->dev);
>  		if (err)
> -			goto err;
> +			goto err_free_device;
>  	}
>  	return 0;
> +
> +err_free_device:
> +	gve_teardown_device_resources(priv);
> +	bitmap_free(priv->xsk_pools);
> +	priv->xsk_pools = NULL;
> +err_free_adminq:
> +	gve_adminq_free(priv);

[Severity: High]
If gve_open() fails here, the error path tears down device resources (freeing
priv->ntfy_blocks) and the admin queue DMA pool via gve_adminq_free().

However, the net_device remains registered. If a user subsequently attempts to
bring the interface up, gve_open() is invoked again. Because gve_open()
currently does not check if resources are initialized, it proceeds to call
gve_queues_start().

Could this trigger a use-after-free in gve_adminq_issue_cmd() (dereferencing
priv->adminq from the destroyed pool) and a null pointer dereference in
gve_turnup() or gve_reg_xdp_info() (dereferencing priv->ntfy_blocks)?

I notice this issue is fixed later in the series by commit d54cafae24e9
("gve: simplify reset logic") which adds a gve_get_device_resources_ok()
check at the start of gve_open().

>  err:
>  	dev_err(&priv->pdev->dev, "Reset failed! !!! DISABLING ALL QUEUES !!!\n");

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260602235900.3050782-1-hramamurthy@google.com?part=8

  reply	other threads:[~2026-06-03 23:59 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 23:58 [PATCH net-next v2 00/15] gve: AdminQ mode related refactors Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 01/15] gve: don't pass in unused parameter to gve_adminq_free Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 02/15] gve: refactor initialization with helper functions Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot
2026-06-05  3:41   ` Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 03/15] gve: introduce gve_adminq_get_device_properties() Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 04/15] gve: add a few helper functions to set device properties Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 05/15] gve: add struct gve_device_info to hold " Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot
2026-06-05  3:44   ` Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 06/15] gve: introduce control plane operations structure Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 07/15] gve: introduce ctrl ops to set vectors and Qs Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 08/15] gve: refactor gve_init_priv for reset path Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot [this message]
2026-06-05  3:52   ` Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 09/15] gve: simplify reset logic Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot
2026-06-07 22:20   ` Joshua Washington
2026-06-02 23:58 ` [PATCH net-next v2 10/15] gve: add gve_ctrl_ops for gve initialization/teardown sequences Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 11/15] gve: split up notify block allocation and setup paths Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot
2026-06-07 22:29   ` Joshua Washington
2026-06-02 23:58 ` [PATCH net-next v2 12/15] gve: introduce new methods to handle IRQ doorbells Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot
2026-06-07 22:35   ` Joshua Washington
2026-06-02 23:58 ` [PATCH net-next v2 13/15] gve: setup and teardown management interrupts Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot
2026-06-07 22:39   ` Joshua Washington
2026-06-02 23:58 ` [PATCH net-next v2 14/15] gve: add ctrl ops to for queue operations Harshitha Ramamurthy
2026-06-05  3:56   ` Harshitha Ramamurthy
2026-06-02 23:58 ` [PATCH net-next v2 15/15] gve: add link status/speed ctrl ops Harshitha Ramamurthy
2026-06-03 23:59   ` sashiko-bot
2026-06-07 22:45   ` Joshua Washington

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=20260603235928.0B9D81F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=hramamurthy@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.