linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mwifiex: prevent an array overflow
@ 2019-04-04  8:44 Dan Carpenter
  2019-04-25 16:50 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2019-04-04  8:44 UTC (permalink / raw)
  To: Amitkumar Karwar, Xinming Hu
  Cc: Nishant Sarmukadam, Ganapathi Bhat, Kalle Valo, linux-wireless,
	kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/wireless/marvell/mwifiex/cfp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/cfp.c b/drivers/net/wireless/marvell/mwifiex/cfp.c
index bfe84e55df77..f1522fb1c1e8 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfp.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfp.c
@@ -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;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mwifiex: prevent an array overflow
  2019-04-04  8:44 [PATCH] mwifiex: prevent an array overflow Dan Carpenter
@ 2019-04-25 16:50 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2019-04-25 16:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Amitkumar Karwar, Xinming Hu, Nishant Sarmukadam, Ganapathi Bhat,
	linux-wireless, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:

> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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

b4c35c17227f mwifiex: prevent an array overflow

-- 
https://patchwork.kernel.org/patch/10885297/

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-25 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-04  8:44 [PATCH] mwifiex: prevent an array overflow Dan Carpenter
2019-04-25 16:50 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).