Skip to contentSkip to conversation

qede: fix out-of-bounds check for cqe->len_list[]

PATCH Applied Matvey Kovalev 2 participants 2 messages Jun 23 – Jun 27

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

PATCH 1/1 qede: fix out-of-bounds check for cqe->len_list[]

Move index check before element access.

Fixes 896f1a2493b5 ("net: qlogic/qede: fix potential out-of-bounds read in qede_tpa_cont() and qede_tpa_end()")

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/net/ethernet/qlogic/qede/qede_fp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/qlogic/qede/qede_fp.c +2 -2
index e338bfc8b7b2..33e18bb69774 100644
@@ -961,7 +961,7 @@ static inline void qede_tpa_cont(struct qede_dev *edev,
 {
 	int i;
 
-	for (i = 0; cqe->len_list[i] && i < ARRAY_SIZE(cqe->len_list); i++)
+	for (i = 0; i < ARRAY_SIZE(cqe->len_list) && cqe->len_list[i]; i++)
 		qede_fill_frag_skb(edev, rxq, cqe->tpa_agg_index,
 				   le16_to_cpu(cqe->len_list[i]));
 
@@ -986,7 +986,7 @@ static int qede_tpa_end(struct qede_dev *edev,
 		dma_unmap_page(rxq->dev, tpa_info->buffer.mapping,
 			       PAGE_SIZE, rxq->data_direction);
 
-	for (i = 0; cqe->len_list[i] && i < ARRAY_SIZE(cqe->len_list); i++)
+	for (i = 0; i < ARRAY_SIZE(cqe->len_list) && cqe->len_list[i]; i++)
 		qede_fill_frag_skb(edev, rxq, cqe->tpa_agg_index,
 				   le16_to_cpu(cqe->len_list[i]));
 	if (unlikely(i > 1))
Signature · 1 line
2.54.0
#1 lore raw
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, 23 Jun 2026 17:45:54 +0300 you wrote:

Move index check before element access.

Fixes 896f1a2493b5 ("net: qlogic/qede: fix potential out-of-bounds read in qede_tpa_cont() and qede_tpa_end()")

Found by Linux Verification Center (linuxtesting.org) with SVACE.

[...]

Here is the summary with links:
- qede: fix out-of-bounds check for cqe->len_list[]

    https://git.kernel.org/netdev/net/c/f9ba47fce593

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html