gve: fix out-of-bounds read in gve_get_flow_rule_entry()
Subsystems (4)
PATCH 1/1 gve: fix out-of-bounds read in gve_get_flow_rule_entry()
gve_get_flow_rule_entry() checks the requested location against the first and last cached rules, but rules_cache_num can be 0 while rules_cache_synced is true: GVE_FLOW_RULE_QUERY_RULES returns the rules from the requested location onwards, so a request past the last installed rule - or any request when no rules are installed - returns zero rules, which the driver accepts and marks as synced.
The next query evaluates rules_cache[*cache_num - 1] with *cache_num == 0. The zero-initialised cache does not trip the earlier comparison, *cache_num - 1 wraps to 0xFFFFFFFF in u32, and the read faults about 352 GiB past the cache. ETHTOOL_GRXCLSRULE needs no capability, so an unprivileged user can trigger it:
BUG: unable to handle page fault for address: ff240996c4c64fa8
#PF: supervisor read access in kernel mode
RIP: gve_get_flow_rule_entry+0xd4/0x110 [gve]Treat an empty cache as a cache miss and re-query.
---
Reproducer available on request.
drivers/net/ethernet/google/gve/gve_flow_rule.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/google/gve/gve_flow_rule.c +1 -0
@@ -206,6 +206,7 @@ int gve_get_flow_rule_entry(struct gve_priv *priv, struct ethtool_rxnfc *cmd)return -EOPNOTSUPP ;if (!priv->flow_rules_cache.rules_cache_synced || + !*cache_num || fsp->location <be32_to_cpu (rules_cache[0 ].location) || fsp->location >be32_to_cpu (rules_cache[*cache_num -1 ].location)) { err =gve_adminq_query_flow_rules (priv,GVE_FLOW_RULE_QUERY_RULES , fsp->location);
Signature · 1 line
2.55.0
Quoted 13 lines
gve_get_flow_rule_entry()checks the requested location against the first and last cached rules, butrules_cache_numcan be 0 whilerules_cache_syncedis true:GVE_FLOW_RULE_QUERY_RULESreturns the rules from the requested location onwards, so a request past the last installed rule - or any request when no rules are installed - returns zero rules, which the driver accepts and marks as synced.The next query evaluates rules_cache[*cache_num - 1] with
*cache_num== 0. The zero-initialised cache does not trip the earlier comparison,*cache_num- 1 wraps to0xFFFFFFFFin u32, and the read faults about 352 GiB past the cache.ETHTOOL_GRXCLSRULEneeds no capability, so an unprivileged user can trigger it:
Quoted 5 lines
BUG: unable to handle page fault for address: ff240996c4c64fa8 #PF: supervisor read access in kernel mode RIP: gve_get_flow_rule_entry+0xd4/0x110 [gve]Treat an empty cache as a cache miss and re-query.
Patch looks great! I had this exact fix queued up internally along with a regression test after reproducing the crash.
Quoted 18 lines · Aamir Ahmed
gve_get_flow_rule_entry()checks the requested location against the first and last cached rules, butrules_cache_numcan be 0 whilerules_cache_syncedis true:GVE_FLOW_RULE_QUERY_RULESreturns the rules from the requested location onwards, so a request past the last installed rule - or any request when no rules are installed - returns zero rules, which the driver accepts and marks as synced.The next query evaluates rules_cache[*cache_num - 1] with
*cache_num== 0. The zero-initialised cache does not trip the earlier comparison,*cache_num- 1 wraps to0xFFFFFFFFin u32, and the read faults about 352 GiB past the cache.ETHTOOL_GRXCLSRULEneeds no capability, so an unprivileged user can trigger it:BUG: unable to handle page fault for address: ff240996c4c64fa8 #PF: supervisor read access in kernel mode RIP: gve_get_flow_rule_entry+0xd4/0x110 [gve]
Quoted 6 lines
Treat an empty cache as a cache miss and re-query.
Fixes 6f3bc487565d ("gve: Add flow steering ethtool support")Assisted-by LLMSigned-off-by Aamir Ahmed <[email protected]>
Thanks for the patch!
Quoted 21 lines
---
Reproducer available on request.drivers/net/ethernet/google/gve/gve_flow_rule.c | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/google/gve/gve_flow_rule.c +1
-1@@ -206,6 +206,7 @@ int gve_get_flow_rule_entry(struct gve_priv *priv, struct ethtool_rxnfc *cmd)return -EOPNOTSUPP ;if (!priv->flow_rules_cache.rules_cache_synced || + !*cache_num || fsp->location <be32_to_cpu (rules_cache[0 ].location) || fsp->location >be32_to_cpu (rules_cache[*cache_num -1 ].location)) { err =gve_adminq_query_flow_rules (priv,GVE_FLOW_RULE_QUERY_RULES , fsp->location); --2.55.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 20 Oct 2026 23:33:46 +0100 you wrote:
gve_get_flow_rule_entry()checks the requested location against the first and last cached rules, butrules_cache_numcan be 0 whilerules_cache_syncedis true:GVE_FLOW_RULE_QUERY_RULESreturns the rules from the requested location onwards, so a request past the last installed rule - or any request when no rules are installed - returns zero rules, which the driver accepts and marks as synced.[...]
Here is the summary with links:
- [net] gve: fix out-of-bounds read in gve_get_flow_rule_entry()
https://git.kernel.org/netdev/net/c/45e0a63f9c86
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html