Skip to contentSkip to conversation

gve: DQO: Fix off by one in gve_rx_dqo()

PATCH Applied Dan Carpenter 2 participants 2 messages Jun 29, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gve: DQO: Fix off by one in gve_rx_dqo()

The rx->dqo.buf_states[] array is allocated in gve_rx_alloc_ring_dqo() and it has rx->dqo.num_buf_states so this > needs to >= to prevent an out of bounds access.

Fixes 9b8dd5e5ea48 ("gve: DQO: Add RX path")
---
 drivers/net/ethernet/google/gve/gve_rx_dqo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_rx_dqo.c +1 -1
index 8738db020061..77bb8227f89b 100644
@@ -525,7 +525,7 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx,
 	struct gve_priv *priv = rx->gve;
 	u16 buf_len;
 
-	if (unlikely(buffer_id > rx->dqo.num_buf_states)) {
+	if (unlikely(buffer_id >= rx->dqo.num_buf_states)) {
 		net_err_ratelimited("%s: Invalid RX buffer_id=%u\n",
 				    priv->dev->name, buffer_id);
 		return -EINVAL;
Signature · 1 line
2.30.2
#1 lore raw
This patch was applied to netdev/net-next.git (refs/heads/master):

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

Quoted 8 lines · On Tue, 29 Jun 2021 11:25:13 +0300 you wrote:

The rx->dqo.buf_states[] array is allocated in gve_rx_alloc_ring_dqo() and it has rx->dqo.num_buf_states so this > needs to >= to prevent an out of bounds access.

Fixes 9b8dd5e5ea48 ("gve: DQO: Add RX path")

[...]

Here is the summary with links:
- [net-next] gve: DQO: Fix off by one in gve_rx_dqo()

    https://git.kernel.org/netdev/net-next/c/ecd89c02da85

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html