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 v5 01/12] gve: add struct gve_device_info to hold device properties
Date: Fri, 04 Sep 2026 21:56:31 +0000	[thread overview]
Message-ID: <20260904215631.72E4B1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260903215606.31633-2-hramamurthy@google.com>

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

Pre-existing issues:
- [High] The driver trusts the device-provided `descriptor->total_length` without clamping it to the actual allocated DMA buffer size, leading to an out-of-bounds read vulnerability.
--

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

gve: add struct gve_device_info to hold device properties

The commit refactors the initialization flow by adding struct gve_device_info
to store negotiated device properties. It fills it in
gve_adminq_describe_device() and its callees to prepare the driver for the
upcoming MailboxQ mode without changing functional behavior.

> diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
> index f05f4895f4c74..512349c5517f4 100644
> --- a/drivers/net/ethernet/google/gve/gve_adminq.c
> +++ b/drivers/net/ethernet/google/gve/gve_adminq.c
> @@ -70,7 +70,7 @@ void gve_parse_device_option(struct gve_priv *priv,
>  
>  		dev_info(&priv->pdev->dev,
>  			 "Gqi raw addressing device option enabled.\n");
> -		priv->queue_format = GVE_GQI_RDA_FORMAT;
> +		priv->device_info.queue_format = GVE_GQI_RDA_FORMAT;
>  		break;

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential
out-of-bounds read vulnerability in the device option parsing logic.

When traversing the options in gve_process_device_options(), the code relies on
gve_get_next_option() which does not clamp the untrusted total_length to the
allocated buffer size:

drivers/net/ethernet/google/gve/gve_adminq.c:gve_get_next_option() {
	void *option_end, *descriptor_end;

	option_end = (void *)(option + 1) + be16_to_cpu(option->option_length);
	descriptor_end = (void *)descriptor + be16_to_cpu(descriptor->total_length);

	return option_end > descriptor_end ? NULL : (struct gve_device_option *)option_end;
}

If a malicious device provides an AdminQ response where
descriptor->total_length exceeds GVE_ADMINQ_BUFFER_SIZE (4096),
descriptor_end will point far beyond the actual allocated DMA buffer.

This could allow gve_get_next_option() to return an out-of-bounds pointer,
which is then dereferenced in the option parsing loop in
gve_process_device_options():

drivers/net/ethernet/google/gve/gve_adminq.c:gve_process_device_options() {
	...
	for (i = 0; i < num_options; i++) {
		struct gve_device_option *next_opt;

		next_opt = gve_get_next_option(descriptor, dev_opt);
	...
}

Could descriptor->total_length be validated against GVE_ADMINQ_BUFFER_SIZE
before using it to calculate descriptor_end?

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

  reply	other threads:[~2026-09-04 21:56 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 21:55 [PATCH net-next v5 00/12] gve: AdminQ mode related refactors Harshitha Ramamurthy
2026-09-03 21:55 ` [PATCH net-next v5 01/12] gve: add struct gve_device_info to hold device properties Harshitha Ramamurthy
2026-09-04 21:56   ` sashiko-bot [this message]
2026-09-07  0:03   ` netdev-bot+sashiko
2026-09-03 21:55 ` [PATCH net-next v5 02/12] gve: introduce control plane operations structure Harshitha Ramamurthy
2026-09-07  0:03   ` netdev-bot+sashiko
2026-09-03 21:55 ` [PATCH net-next v5 03/12] gve: introduce ctrl ops to set vectors and Qs Harshitha Ramamurthy
2026-09-03 21:55 ` [PATCH net-next v5 04/12] gve: introduce gve_adminq_get_device_properties() Harshitha Ramamurthy
2026-09-03 21:55 ` [PATCH net-next v5 05/12] gve: refactor gve_init_priv for reset path Harshitha Ramamurthy
2026-09-07  0:03   ` netdev-bot+sashiko
2026-09-03 21:56 ` [PATCH net-next v5 06/12] gve: simplify reset logic Harshitha Ramamurthy
2026-09-04 21:56   ` sashiko-bot
2026-09-07  0:03   ` netdev-bot+sashiko
2026-09-03 21:56 ` [PATCH net-next v5 07/12] gve: add gve_ctrl_ops for gve initialization/teardown sequences Harshitha Ramamurthy
2026-09-04 21:56   ` sashiko-bot
2026-09-03 21:56 ` [PATCH net-next v5 08/12] gve: split up notify block allocation and setup paths Harshitha Ramamurthy
2026-09-07  0:04   ` netdev-bot+sashiko
2026-09-03 21:56 ` [PATCH net-next v5 09/12] gve: introduce new methods to handle IRQ doorbells Harshitha Ramamurthy
2026-09-04 21:56   ` sashiko-bot
2026-09-07  0:04   ` netdev-bot+sashiko
2026-09-03 21:56 ` [PATCH net-next v5 10/12] gve: setup and teardown management interrupts Harshitha Ramamurthy
2026-09-04 21:56   ` sashiko-bot
2026-09-03 21:56 ` [PATCH net-next v5 11/12] gve: add ctrl ops to for queue operations Harshitha Ramamurthy
2026-09-07  0:04   ` netdev-bot+sashiko
2026-09-03 21:56 ` [PATCH net-next v5 12/12] gve: add link status/speed ctrl ops Harshitha Ramamurthy
2026-09-04 21:56   ` sashiko-bot
2026-09-07  0:04   ` netdev-bot+sashiko
2026-09-08 10:09 ` [PATCH net-next v5 00/12] gve: AdminQ mode related refactors Paolo Abeni
2026-09-08 15:12   ` Harshitha Ramamurthy

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=20260904215631.72E4B1F00A3D@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.