FAILED: patch "[PATCH] gve: Block invalid ring sizes when device options are 0" failed to apply to 7.3-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 7.3-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.3.y
git checkout FETCH_HEAD
git cherry-pick -x edc9a730ad3c98662047a76db2d7f26ea4350b2e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112542-ethanol-oasis-b0ce@gregkh' --subject-prefix 'PATCH 7.3.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From edc9a730ad3c98662047a76db2d7f26ea4350b2e Mon Sep 17 00:00:00 2001
From: Pin-yen Lin <[email protected]>
Date: Mon, 9 Nov 2026 18:20:35 +0000
Subject: [PATCH] gve: Block invalid ring sizes when device options are 0
On older device versions, minimum ring sizes in the device option are reported as 0. The driver imports these 0 values, allowing userspace (ethtool -G) to request invalidly small ring sizes.
This issue was discovered and actually triggered by the drivers/net/ring_reconfig.py selftest (ringparam test case). Halving the ring size down to 1 triggered a kernel NULL pointer dereference in gve_tx_alloc_rings_dqo():
BUG: kernel NULL pointer dereference, address: 0000000000000002 RIP: 0010:gve_tx_alloc_rings_dqo+0x1c4/0x510 [gve] Call Trace: <TASK> gve_queues_mem_alloc+0x29/0xa0 [gve] gve_adjust_config+0x1b/0x140 [gve] gve_set_ringparam+0x1f4/0x250 [gve] ethnl_set_rings+0x260/0x440 ...
Fix this by falling back to the driver's default minimum ring sizes (GVE_DEFAULT_MIN_RX_RING_SIZE and GVE_DEFAULT_MIN_TX_RING_SIZE) whenever the device option reports minimum ring sizes as 0.
The device reports either both minimum ring sizes or neither, so a single fallback for both is sufficient.
This change was tested using the DQO RDA queue format.
drivers/net/ethernet/google/gve/gve_adminq.c +3 -1
@@ -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;break ;case GVE_DEV_OPT_ID_FLOW_STEERING :
Sasha Levin
maintainerPATCH 1/2 gve: add struct gve_device_info to hold device properties
From: Harshitha Ramamurthy <[email protected]>
[ Upstream commit 130634764549aa3c4745ee96db57443ded848611 ]
In the current AdminQ mode, device properties are written into struct gve_device_descriptor that is allocated in shared memory between the driver and device. In the upcoming MailboxQ mode, these properties will be returned in the response of a mailbox message. Hence, add struct gve_device_info as the structure that holds all the properties that are negotiated with the device in either mode.
Change the AdminQ mode method gve_adminq_describe_device() and its children to fill up device information into this newly introduced struct gve_device_info. Move a few helper functions and code that set device properties in the priv structure into gve_init_priv(). So now gve_init_priv() calls/does the following:
- gve_set_mtu()
- gve_set_mac()
- gve_set_queue_properties()
- gve_set_buf_sizes()
- set flow steering and RSS properties
- set other priv properties
When MailboxQ support is added, device information will be filled into the same structure and the same gve_init_priv() path would be used to set device properties to ensure common code reusage.
Most of these changes are refactors only, except for one:
with the introduction of the central struct gve_device_info, in AdminQ mode, gve_set_mtu() now validates the final max mtu:
the mtu from the device descriptor, or the jumbo frames device option value when it is present. Previously only the descriptor mtu was validated. This sets up the driver nicely for the MailboxQ mode where both the default and the maximum mtu are provided at once and they are validated in gve_set_mtu().
Stable-dep-of: edc9a730ad3c ("gve: Block invalid ring sizes when device options are 0")
--- drivers/net/ethernet/google/gve/gve.h | 29 +++++ drivers/net/ethernet/google/gve/gve_adminq.c | 128 +++++++++++-------- drivers/net/ethernet/google/gve/gve_adminq.h | 6 - drivers/net/ethernet/google/gve/gve_main.c | 86 +++++++++---- 4 files changed, 169 insertions(+), 80 deletions(-)
drivers/net/ethernet/google/gve/gve.h +29 -0
@@ -797,6 +797,34 @@ struct gve_ptp {struct gve_priv *priv; }; +struct gve_device_info { +enum gve_queue_format queue_format; +u16 default_tx_queues; +u16 default_rx_queues; +u16 max_tx_queues; +u16 max_rx_queues; +u16 default_tx_ring_size; +u16 default_rx_ring_size; +u16 max_tx_ring_size; +u16 max_rx_ring_size; +u16 min_tx_ring_size; +u16 min_rx_ring_size; +u16 max_mtu; +u8 mac[ETH_ALEN ]; +u16 max_rx_buffer_size; +u16 header_buf_size; +u32 max_flow_rules; +u16 rss_key_size; +u16 rss_lut_size; +u16 tx_pages_per_qpl; +u16 num_event_counters; +u64 max_registered_pages; +bool default_min_ring_size; +bool nic_timestamp_supported; +bool modify_ring_size_enabled; +bool cache_rss_config; +}; +struct gve_priv {struct net_device *dev;struct gve_tx_ring *tx;/* array of tx_cfg.num_queues */
@@ -929,6 +957,7 @@ struct gve_priv {struct gve_nic_ts_report *nic_ts_report;dma_addr_t nic_ts_report_bus;u64 last_sync_nic_counter;/* Clock counter from last NIC TS report */ +struct gve_device_info device_info; };enum gve_service_task_flags_bit {
drivers/net/ethernet/google/gve/gve_adminq.c +78 -50
245 lines not on this page · raw message
drivers/net/ethernet/google/gve/gve_adminq.h +0 -6
@@ -658,10 +658,4 @@ int gve_adminq_get_ptype_map_dqo(struct gve_priv *priv, struct gve_ptype_lut *ptype_lut);int gve_set_num_ntfy_blks (struct gve_priv *priv);void gve_set_num_queues (struct gve_priv *priv); -void gve_set_queue_properties (struct gve_priv *priv, -struct gve_device_descriptor *descriptor); -int gve_set_mtu (struct gve_priv *priv, -struct gve_device_descriptor *descriptor); -void gve_set_mac (struct gve_priv *priv, -struct gve_device_descriptor *descriptor);#endif /* _GVE_ADMINQ_H */
drivers/net/ethernet/google/gve/gve_main.c +62 -24
144 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 gve: Block invalid ring sizes when device options are 0
From: Pin-yen Lin <[email protected]>
[ Upstream commit edc9a730ad3c98662047a76db2d7f26ea4350b2e ]
On older device versions, minimum ring sizes in the device option are reported as 0. The driver imports these 0 values, allowing userspace (ethtool -G) to request invalidly small ring sizes.
This issue was discovered and actually triggered by the drivers/net/ring_reconfig.py selftest (ringparam test case). Halving the ring size down to 1 triggered a kernel NULL pointer dereference in gve_tx_alloc_rings_dqo():
BUG: kernel NULL pointer dereference, address: 0000000000000002 RIP: 0010:gve_tx_alloc_rings_dqo+0x1c4/0x510 [gve] Call Trace: <TASK> gve_queues_mem_alloc+0x29/0xa0 [gve] gve_adjust_config+0x1b/0x140 [gve] gve_set_ringparam+0x1f4/0x250 [gve] ethnl_set_rings+0x260/0x440 ...
Fix this by falling back to the driver's default minimum ring sizes (GVE_DEFAULT_MIN_RX_RING_SIZE and GVE_DEFAULT_MIN_TX_RING_SIZE) whenever the device option reports minimum ring sizes as 0.
The device reports either both minimum ring sizes or neither, so a single fallback for both is sufficient.
This change was tested using the DQO RDA queue format.
--- drivers/net/ethernet/google/gve/gve_adminq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_adminq.c +3 -1
@@ -189,7 +189,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;break ;case GVE_DEV_OPT_ID_FLOW_STEERING :
Signature · 1 line
2.53.0