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 v4 08/15] gve: refactor gve_init_priv for reset path
Date: Sat, 15 Aug 2026 02:14:37 +0000	[thread overview]
Message-ID: <20260815021437.A03991F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814021406.3044324-9-hramamurthy@google.com>

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

Pre-existing issues:
- [High] AF_XDP socket pool bindings are silently detached and forgotten upon driver reset.
- [High] Background tasks (`stats_report_task`, `service_task`) are not canceled before the resources they depend on are freed, leading to a Use-After-Free and kernel panic.
- [High] Null Pointer Dereference in `gve_xsk_pool_enable` and `gve_xsk_pool_disable` if device setup fails.
--

--- Patch [8]: [PATCH net-next v4 08/15] gve: refactor gve_init_priv for reset path ---
commit eabed5dc37b0260679aedc435501a49d2e938fb5
Author: Harshitha Ramamurthy <hramamurthy@google.com>

gve: refactor gve_init_priv for reset path

The driver does not need to renegotiate all properties with
the device on a reset since those should stay constant through
a reset. Hence change gve_init_priv() into a method that only
sets these properties into the priv structure and hence needs
to be only called once during gve_probe().

> --- a/drivers/net/ethernet/google/gve/gve_main.c
> +++ b/drivers/net/ethernet/google/gve/gve_main.c
[ ... ]
> +static int gve_setup_device(struct gve_priv *priv)
> +{
> +	int err;
> +
> +	priv->num_registered_pages = 0;
> +
> +	priv->xsk_pools = bitmap_zalloc(priv->rx_cfg.max_queues, GFP_KERNEL);

[Severity: High]
This isn't a bug introduced by this patch, but does this allocation silently
detach and forget existing AF_XDP socket pool bindings upon a driver reset?

If a driver reset occurs, for example due to a Tx timeout, the recovery path
calls gve_setup_device() which unconditionally allocates a new, zeroed
xsk_pools bitmap.

When queues restart, gve_reg_xdp_info() will find no registered pools and
configure the hardware for standard traffic instead of zero-copy. Could this
cause existing AF_XDP applications to stop receiving and sending packets
without notification?

> +	if (!priv->xsk_pools) {
> +		err = -ENOMEM;
> +		goto err;
> +	}
> +
> +	gve_set_netdev_xdp_features(priv);
> +	if (!gve_is_gqi(priv))
> +		priv->dev->xdp_metadata_ops = &gve_xdp_metadata_ops;
> +
> +	err = gve_setup_device_resources(priv);
> +	if (err)
> +		goto err_free_xsk_bitmap;
> +
> +	return 0;
> +
> +err_free_xsk_bitmap:
> +	bitmap_free(priv->xsk_pools);
> +	priv->xsk_pools = NULL;

[Severity: High]
This is a pre-existing issue, but can this lead to a NULL pointer
dereference if the device setup fails?

If gve_setup_device() fails during a reset recovery and frees the bitmap,
xsk_pools is set to NULL. If a privileged user then attempts to attach or
detach an AF_XDP socket before the device is fully recovered:

gve_xsk_pool_enable()
    set_bit(qid, priv->xsk_pools);

Would this unconditionally dereference the NULL priv->xsk_pools pointer?

> +err:
> +	return err;
> +}
[ ... ]
> -err_free_xsk_bitmap:
> -	bitmap_free(priv->xsk_pools);
> -	priv->xsk_pools = NULL;
> -err:
> -	gve_adminq_free(priv);
> -	return err;
>  }
>  
>  static void gve_teardown_priv_resources(struct gve_priv *priv)

[Severity: High]
This is a pre-existing issue not touched by this patch, but does the driver
have a use-after-free during module removal?

In gve_remove(), gve_teardown_priv_resources() is called before
destroy_workqueue(). This frees priv->stats_report.

Because the driver does not cancel the background tasks before freeing these
resources, if stats_report_task is queued, destroy_workqueue() will flush
and execute it. Could this cause gve_handle_report_stats() to dereference
the freed stats_report pointer and panic?

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

  reply	other threads:[~2026-08-15  2:14 UTC|newest]

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

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=20260815021437.A03991F000E9@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.