Skip to contentSkip to conversation

mwifiex: prevent an array overflow

PATCH In review Dan Carpenter 2 participants 2 messages Apr 4, 2019 – Apr 25, 2019

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

PATCH 1/1 mwifiex: prevent an array overflow

The "rate_index" is only used as an index into the phist_data->rx_rate[] array in the mwifiex_hist_data_set() function. That array has MWIFIEX_MAX_AC_RX_RATES (74) elements and it's used to generate some debugfs information. The "rate_index" variable comes from the network skb->data[] and it is a u8 so it's in the 0-255 range. We need to cap it to prevent an array overflow.

Fixes cbf6e05527a7 ("mwifiex: add rx histogram statistics support")
---
 drivers/net/wireless/marvell/mwifiex/cfp.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/wireless/marvell/mwifiex/cfp.c +3 -0
index bfe84e55df77..f1522fb1c1e8 100644
@@ -531,5 +531,8 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
 		rate_index = (rx_rate > MWIFIEX_RATE_INDEX_OFDM0) ?
 			      rx_rate - 1 : rx_rate;
 
+	if (rate_index >= MWIFIEX_MAX_AC_RX_RATES)
+		rate_index = MWIFIEX_MAX_AC_RX_RATES - 1;
+
 	return rate_index;
 }
Signature · 1 line
2.17.1
#1 lore raw
Quoted 9 lines · Dan Carpenter

The "rate_index" is only used as an index into the phist_data->rx_rate[] array in the mwifiex_hist_data_set() function. That array has MWIFIEX_MAX_AC_RX_RATES (74) elements and it's used to generate some debugfs information. The "rate_index" variable comes from the network skb->data[] and it is a u8 so it's in the 0-255 range. We need to cap it to prevent an array overflow.

Fixes cbf6e05527a7 ("mwifiex: add rx histogram statistics support")

Patch applied to wireless-drivers-next.git, thanks.

b4c35c17227f mwifiex: prevent an array overflow

Signature · 3 lines
https://patchwork.kernel.org/patch/10885297/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches