Skip to contentSkip to conversation

cxgb3: fix out of bounds read

PATCH Applied Michal Schmidt 3 participants 3 messages Apr 29, 2016 – May 2, 2016

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

PATCH 1/1 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[].

---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +2 -1
index 60908eab3b..43da891fab 100644
@@ -576,7 +576,7 @@ static void setup_rss(struct adapter *adap)
 	unsigned int nq0 = adap2pinfo(adap, 0)->nqsets;
 	unsigned int nq1 = adap->port[1] ? adap2pinfo(adap, 1)->nqsets : 1;
 	u8 cpus[SGE_QSETS + 1];
-	u16 rspq_map[RSS_TABLE_SIZE];
+	u16 rspq_map[RSS_TABLE_SIZE + 1];
 
 	for (i = 0; i < SGE_QSETS; ++i)
 		cpus[i] = i;
@@ -586,6 +586,7 @@ static void setup_rss(struct adapter *adap)
 		rspq_map[i] = i % nq0;
 		rspq_map[i + RSS_TABLE_SIZE / 2] = (i % nq1) + nq0;
 	}
+	rspq_map[RSS_TABLE_SIZE] = 0xffff; /* terminator */
 
 	t3_config_rss(adap, F_RQFEEDBACKENABLE | F_TNLLKPEN | F_TNLMAPEN |
 		      F_TNLPRTEN | F_TNL2TUPEN | F_TNL4TUPEN |
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: Michal Schmidt <[email protected]>
Date: Fri, 29 Apr 2016 11:06:50 +0200

Quoted 8 lines

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.

Quoted 4 lines

Add the missing terminator to rspq_map[].

Applied.

#2 lore raw

----- Original Message -----

Quoted 17 lines

From: "David Miller" <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Sent: Monday, 2 May, 2016 3:00:00 AM
Subject: Re: [PATCH net] cxgb3: fix out of bounds read

From: Michal Schmidt <[email protected]>
Date: Fri, 29 Apr 2016 11:06:50 +0200

Quoted 8 lines

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.

Quoted 7 lines
Quoted 4 lines

Add the missing terminator to rspq_map[].

Applied.

KASAN BUG message went away for me with this patch.

Regards,
Jan