Skip to content

Commit 896f1a2

Browse files
Pavel ZhigulinPaolo Abeni
authored andcommitted
net: qlogic/qede: fix potential out-of-bounds read in qede_tpa_cont() and qede_tpa_end()
The loops in 'qede_tpa_cont()' and 'qede_tpa_end()', iterate over 'cqe->len_list[]' using only a zero-length terminator as the stopping condition. If the terminator was missing or malformed, the loop could run past the end of the fixed-size array. Add an explicit bound check using ARRAY_SIZE() in both loops to prevent a potential out-of-bounds access. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 55482ed ("qede: Add slowpath/fastpath support and enable hardware GRO") Signed-off-by: Pavel Zhigulin <Pavel.Zhigulin@kaspersky.com> Link: https://patch.msgid.link/20251113112757.4166625-1-Pavel.Zhigulin@kaspersky.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 8e0a754 commit 896f1a2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/ethernet/qlogic/qede/qede_fp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (c) 2019-2020 Marvell International Ltd.
55
*/
66

7+
#include <linux/array_size.h>
78
#include <linux/netdevice.h>
89
#include <linux/etherdevice.h>
910
#include <linux/skbuff.h>
@@ -960,7 +961,7 @@ static inline void qede_tpa_cont(struct qede_dev *edev,
960961
{
961962
int i;
962963

963-
for (i = 0; cqe->len_list[i]; i++)
964+
for (i = 0; cqe->len_list[i] && i < ARRAY_SIZE(cqe->len_list); i++)
964965
qede_fill_frag_skb(edev, rxq, cqe->tpa_agg_index,
965966
le16_to_cpu(cqe->len_list[i]));
966967

@@ -985,7 +986,7 @@ static int qede_tpa_end(struct qede_dev *edev,
985986
dma_unmap_page(rxq->dev, tpa_info->buffer.mapping,
986987
PAGE_SIZE, rxq->data_direction);
987988

988-
for (i = 0; cqe->len_list[i]; i++)
989+
for (i = 0; cqe->len_list[i] && i < ARRAY_SIZE(cqe->len_list); i++)
989990
qede_fill_frag_skb(edev, rxq, cqe->tpa_agg_index,
990991
le16_to_cpu(cqe->len_list[i]));
991992
if (unlikely(i > 1))

0 commit comments

Comments
 (0)