BPF List
 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 15/15] gve: add link status/speed ctrl ops
Date: Sat, 15 Aug 2026 02:14:40 +0000	[thread overview]
Message-ID: <20260815021441.0493D1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260814021406.3044324-16-hramamurthy@google.com>

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

Pre-existing issues:
- [Critical] DMA Use-After-Free due to missing device reset on Admin Queue command timeout.
--

--- Patch [15]: [PATCH net-next v4 15/15] gve: add link status/speed ctrl ops ---
commit bafe15595d2df2fbd631b0f3f40244e39beaf6e5
Author: Joshua Washington <joshwash@google.com>

gve: add link status/speed ctrl ops

This commit refactors the link status check to use a control plane op and
introduces a new op for retrieving the link status in AQ mode from the device
status register. It also adds an op for retrieving link speed in AQ mode which
calls into gve_adminq_report_link_speed.

> diff --git a/drivers/net/ethernet/google/gve/gve_ethtool.c b/drivers/net/ethernet/google/gve/gve_ethtool.c
> index 8199738ba979e..a3220c6514382 100644
> --- a/drivers/net/ethernet/google/gve/gve_ethtool.c
> +++ b/drivers/net/ethernet/google/gve/gve_ethtool.c

[ ... ]

> @@ -749,12 +749,11 @@ static int gve_get_link_ksettings(struct net_device *netdev,
>  	int err = 0;
>  
>  	if (priv->link_speed == 0)
> -		err = gve_adminq_report_link_speed(priv);
> +		err = priv->ctrl_ops->report_link_speed(priv);

[Severity: Critical]
This isn't a bug introduced by this patch, but while reviewing the use of
the report_link_speed control operation, I noticed a pre-existing
regression when handling Admin Queue timeouts.

Could the underlying gve_adminq_report_link_speed() function corrupt memory
if the device responds late?

In drivers/net/ethernet/google/gve/gve_adminq.c,
gve_adminq_report_link_speed() unconditionally frees the DMA region:

    err = gve_adminq_execute_cmd(priv, &gvnic_cmd);

    priv->link_speed = be64_to_cpu(*link_speed_region);
    dma_free_coherent(&priv->pdev->dev, sizeof(*link_speed_region),
                      link_speed_region, link_speed_region_bus);

If the hardware is delayed and gve_adminq_execute_cmd() returns a timeout,
the DMA memory is freed without synchronously resetting or quiescing the
device.

If the hardware later completes the command, could it write the link speed
into the now-freed DMA address and corrupt newly allocated memory?

A similar unconditional free after timeout happens in
gve_adminq_execute_extended_cmd():

    err = gve_adminq_execute_cmd(priv, &cmd);

    dma_free_coherent(&priv->pdev->dev, cmd_size, inner_cmd, inner_cmd_bus);

Since an unprivileged user can trigger this path via ethtool, does the
hardware need to be reset before freeing these DMA buffers, or should the
buffers be leaked until a reset is guaranteed?

>  
>  	cmd->base.speed = priv->link_speed;
>  
>  	cmd->base.duplex = DUPLEX_FULL;
> -
>  	return err;
>  }

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

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

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=20260815021441.0493D1F00A3D@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox