Skip to content

Commit 0b86a2a

Browse files
michichdavem330
authored andcommitted
cxgb3: fix out of bounds read
An out of bounds read of 2 bytes was discovered in cxgb3 with KASAN. t3_config_rss() expects both arrays it gets as parameters to have terminators. setup_rss(), the caller, forgets to add a terminator to one of the arrays. Thankfully the iteration in t3_config_rss() stops anyway, but in the last iteration the check for the terminator is an out of bounds read. Add the missing terminator to rspq_map[]. Reported-by: Jan Stancek <jstancek@redhat.com> Signed-off-by: Michal Schmidt <mschmidt@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c489565 commit 0b86a2a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ static void setup_rss(struct adapter *adap)
576576
unsigned int nq0 = adap2pinfo(adap, 0)->nqsets;
577577
unsigned int nq1 = adap->port[1] ? adap2pinfo(adap, 1)->nqsets : 1;
578578
u8 cpus[SGE_QSETS + 1];
579-
u16 rspq_map[RSS_TABLE_SIZE];
579+
u16 rspq_map[RSS_TABLE_SIZE + 1];
580580

581581
for (i = 0; i < SGE_QSETS; ++i)
582582
cpus[i] = i;
@@ -586,6 +586,7 @@ static void setup_rss(struct adapter *adap)
586586
rspq_map[i] = i % nq0;
587587
rspq_map[i + RSS_TABLE_SIZE / 2] = (i % nq1) + nq0;
588588
}
589+
rspq_map[RSS_TABLE_SIZE] = 0xffff; /* terminator */
589590

590591
t3_config_rss(adap, F_RQFEEDBACKENABLE | F_TNLLKPEN | F_TNLMAPEN |
591592
F_TNLPRTEN | F_TNL2TUPEN | F_TNL4TUPEN |

0 commit comments

Comments
 (0)