* [PATCH net] gve: fix out-of-bounds read in gve_get_flow_rule_entry()
@ 2026-10-20 22:33 Aamir Ahmed
2026-10-21 17:34 ` Eugene Lee
2026-10-21 17:54 ` Harshitha Ramamurthy
0 siblings, 2 replies; 3+ messages in thread
From: Aamir Ahmed @ 2026-10-20 22:33 UTC (permalink / raw)
To: netdev
Cc: Aamir Ahmed, Joshua Washington, Harshitha Ramamurthy,
Andrew Lunn, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, stable, linux-kernel
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.
Fixes: 6f3bc487565d ("gve: Add flow steering ethtool support")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
---
Reproducer available on request.
drivers/net/ethernet/google/gve/gve_flow_rule.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/google/gve/gve_flow_rule.c b/drivers/net/ethernet/google/gve/gve_flow_rule.c
index 2c80cda..db8b9a3 100644
--- a/drivers/net/ethernet/google/gve/gve_flow_rule.c
+++ b/drivers/net/ethernet/google/gve/gve_flow_rule.c
@@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] gve: fix out-of-bounds read in gve_get_flow_rule_entry()
2026-10-20 22:33 [PATCH net] gve: fix out-of-bounds read in gve_get_flow_rule_entry() Aamir Ahmed
@ 2026-10-21 17:34 ` Eugene Lee
2026-10-21 17:54 ` Harshitha Ramamurthy
1 sibling, 0 replies; 3+ messages in thread
From: Eugene Lee @ 2026-10-21 17:34 UTC (permalink / raw)
To: elb12345
Cc: andrew+netdev, davem, edumazet, hramamurthy, jordanrhee,
joshwash, kuba, linux-kernel, netdev, pabeni, stable, Eugene Lee
> 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.
Patch looks great! I had this exact fix queued up internally along with
a regression test after reproducing the crash.
Reviewed-by: Eugene Lee <eugenehlee@google.com>
Tested-by: Eugene Lee <eugenehlee@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] gve: fix out-of-bounds read in gve_get_flow_rule_entry()
2026-10-20 22:33 [PATCH net] gve: fix out-of-bounds read in gve_get_flow_rule_entry() Aamir Ahmed
2026-10-21 17:34 ` Eugene Lee
@ 2026-10-21 17:54 ` Harshitha Ramamurthy
1 sibling, 0 replies; 3+ messages in thread
From: Harshitha Ramamurthy @ 2026-10-21 17:54 UTC (permalink / raw)
To: Aamir Ahmed
Cc: netdev, Joshua Washington, Andrew Lunn, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, stable, linux-kernel
On Tue, Oct 20, 2026 at 3:33 PM Aamir Ahmed <elb12345@hotmail.co.uk> wrote:
>
> 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.
>
> Fixes: 6f3bc487565d ("gve: Add flow steering ethtool support")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
Thanks for the patch!
Reviewed-by: Harshitha Ramamurthy <hramamurthy@google.com>
> ---
> Reproducer available on request.
>
> drivers/net/ethernet/google/gve/gve_flow_rule.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/google/gve/gve_flow_rule.c b/drivers/net/ethernet/google/gve/gve_flow_rule.c
> index 2c80cda..db8b9a3 100644
> --- a/drivers/net/ethernet/google/gve/gve_flow_rule.c
> +++ b/drivers/net/ethernet/google/gve/gve_flow_rule.c
> @@ -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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-21 17:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20 22:33 [PATCH net] gve: fix out-of-bounds read in gve_get_flow_rule_entry() Aamir Ahmed
2026-10-21 17:34 ` Eugene Lee
2026-10-21 17:54 ` Harshitha Ramamurthy
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®