mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: hramamurthy@google.com
Cc: netdev@vger.kernel.org, joshwash@google.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, jordanrhee@google.com,
	willemb@google.com, przemyslaw.kitszel@intel.com,
	nktgrg@google.com, maolson@google.com, jacob.e.keller@intel.com,
	pkaligineedi@google.com, yangchun@google.com,
	patricion@google.com, awogbemila@google.com,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org,
	treapking@google.com
Subject: Re: [PATCH net v3 3/4] gve: Block invalid ring sizes when device options are 0
Date: Tue, 27 Oct 2026 01:42:07 +0000	[thread overview]
Message-ID: <179306532757.3134.16501377800126286936@kernel.org> (raw)
In-Reply-To: <20261023204706.3112215-4-hramamurthy@google.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In gve_parse_device_option()
  (drivers/net/ethernet/google/gve/gve_adminq.c:194-197), the new…

Pre-existing issues:
- [Low] gve_parse_device_option() (gve_adminq.c:177-197) accepts
  MODIFY_RING options with option_length 9-11, because it rejects only <…

--

gve: Block invalid ring sizes when device options are 0

When the MODIFY_RING device option reports a minimum RX or TX ring size
of 0, this patch makes gve_parse_device_option() fall back to the
driver's default minimum ring sizes. The goal is to stop ethtool -G from
accepting ring sizes small enough to crash gve_tx_alloc_rings_dqo().

> diff --git a/drivers/net/ethernet/google/gve/gve_adminq.c b/drivers/net/ethernet/google/gve/gve_adminq.c
> index 8b215fca9c1b6..2c848f0c23dc2 100644
> --- a/drivers/net/ethernet/google/gve/gve_adminq.c
> +++ b/drivers/net/ethernet/google/gve/gve_adminq.c
> @@ -191,7 +191,9 @@ void gve_parse_device_option(struct gve_priv *priv,
>  		*dev_op_modify_ring = (void *)(option + 1);
>  
>  		/* device has not provided min ring size */
> -		if (option_length == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE)
> +		if (option_length == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE ||
> +		    be16_to_cpu((*dev_op_modify_ring)->min_rx_ring_size) == 0 ||
> +		    be16_to_cpu((*dev_op_modify_ring)->min_tx_ring_size) == 0)
>  			priv->device_info.default_min_ring_size = true;

[Severity: Low]
If only one of these two fields is 0, should the other minimum from the
device be kept?

Both directions share the single default_min_ring_size flag. When it is
set, gve_enable_supported_features() replaces both minimums:

drivers/net/ethernet/google/gve/gve_adminq.c:gve_enable_supported_features() {
    ...
		if (info->default_min_ring_size) {
			/* If device hasn't provided minimums, use default minimums */
			info->min_tx_ring_size = GVE_DEFAULT_MIN_TX_RING_SIZE;
			info->min_rx_ring_size = GVE_DEFAULT_MIN_RX_RING_SIZE;
		} else {
    ...
}

Take a device that reports min_rx_ring_size = 1024 and
min_tx_ring_size = 0. Its RX minimum would become
GVE_DEFAULT_MIN_RX_RING_SIZE (512), not 1024. Before this patch, the
non-zero value was used.

gve_set_desc_cnt() copies these values into priv->min_rx_desc_cnt and
priv->min_tx_desc_cnt. Those are the only lower bounds that
gve_validate_req_ring_size() checks:

drivers/net/ethernet/google/gve/gve_ethtool.c:gve_validate_req_ring_size() {
    ...
	if (new_tx_desc_cnt < priv->min_tx_desc_cnt ||
	    new_tx_desc_cnt > priv->max_tx_desc_cnt ||
	    new_rx_desc_cnt < priv->min_rx_desc_cnt ||
    ...
}

Would ethtool -G rx 512 then pass validation and go to the device, even
though it is below the minimum the device reported?

A per-field fallback would use the default only for the field that is 0.
Could that fix the zero-minimum crash and still keep the other limit from
the device? For older devices that report both minimums as 0, as the
commit message describes, the two approaches behave the same.

[Severity: Low]
This is a pre-existing issue, but can these new reads go past the end of
the option payload when option_length is 9, 10 or 11?

The length check earlier in this case rejects only lengths below
GVE_DEVICE_OPTION_NO_MIN_RING_SIZE (8):

drivers/net/ethernet/google/gve/gve_adminq.c:gve_parse_device_option() {
    ...
	case GVE_DEV_OPT_ID_MODIFY_RING:
		if (option_length < GVE_DEVICE_OPTION_NO_MIN_RING_SIZE ||
		    req_feat_mask != GVE_DEV_OPT_REQ_FEAT_MASK_MODIFY_RING) {
    ...
}

min_rx_ring_size and min_tx_ring_size sit at payload offsets 8 and 10,
and sizeof(struct gve_device_option_modify_ring) is 12. With a length of
9 to 11, part of each read comes from the next option header or from
unused descriptor space.

gve_get_next_option() only checks option_length against the
device-provided total_length. Also, total_length is never checked
against the GVE_ADMINQ_BUFFER_SIZE allocation.

If those out-of-option bytes are non-zero, the fallback does not fire
and the bytes are used as the device minimums.

The baseline gve_enable_supported_features() already read the same
fields in this case, because default_min_ring_size stayed false. So this
patch does not add any new reachable impact.

Would checking option_length < sizeof(**dev_op_modify_ring), instead of
comparing with == GVE_DEVICE_OPTION_NO_MIN_RING_SIZE, close this?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261023204706.3112215-1-hramamurthy%40google.com

  reply	other threads:[~2026-10-27  1:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 20:47 [PATCH net v3 0/4] gve: Fixes for issues discovered via net selftests and Sashiko Harshitha Ramamurthy
2026-10-23 20:47 ` [PATCH net v3 1/4] gve: Fix race between stats query and queue reconfig Harshitha Ramamurthy
2026-10-27  1:42   ` netdev-bot+sashiko
2026-10-27 14:51     ` Pin-yen Lin
2026-10-23 20:47 ` [PATCH net v3 2/4] gve: Fix backward stats when interface goes down or configuration is adjusted Harshitha Ramamurthy
2026-10-27  1:42   ` netdev-bot+sashiko
2026-10-27 14:51     ` Pin-yen Lin
2026-10-23 20:47 ` [PATCH net v3 3/4] gve: Block invalid ring sizes when device options are 0 Harshitha Ramamurthy
2026-10-27  1:42   ` netdev-bot+sashiko [this message]
2026-10-27 14:51     ` Pin-yen Lin
2026-10-23 20:47 ` [PATCH net v3 4/4] gve: Fix link flap after ethtool ops Harshitha Ramamurthy
2026-10-27  1:42   ` netdev-bot+sashiko
2026-10-27 14:51     ` Pin-yen Lin

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=179306532757.3134.16501377800126286936@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=awogbemila@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maolson@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=nktgrg@google.com \
    --cc=pabeni@redhat.com \
    --cc=patricion@google.com \
    --cc=pkaligineedi@google.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=treapking@google.com \
    --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®