Skip to content

Commit 49a27ee

Browse files
panjaneygregkh
authored andcommitted
wifi: iwlwifi: add a few rate index validity checks
commit efbe8f81952fe469d38655744627d860879dcde8 upstream. Validate index before access iwl_rate_mcs to keep rate->index inside the valid boundaries. Use MCS_0_INDEX if index is less than MCS_0_INDEX and MCS_9_INDEX if index is greater then MCS_9_INDEX. Signed-off-by: Anjaneyulu <[email protected]> Signed-off-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/20230614123447.79f16b3aef32.If1137f894775d6d07b78cbf3a6163ffce6399507@changeid Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 182a4b7 commit 49a27ee

File tree

2 files changed

+12
-6
lines changed
  • drivers/net/wireless/intel/iwlwifi

2 files changed

+12
-6
lines changed

drivers/net/wireless/intel/iwlwifi/dvm/rs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/******************************************************************************
33
*
44
* Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
5-
* Copyright (C) 2019 - 2020, 2022 Intel Corporation
5+
* Copyright (C) 2019 - 2020, 2022 - 2023 Intel Corporation
66
*****************************************************************************/
77
#include <linux/kernel.h>
88
#include <linux/skbuff.h>
@@ -125,7 +125,7 @@ static int iwl_hwrate_to_plcp_idx(u32 rate_n_flags)
125125
return idx;
126126
}
127127

128-
return -1;
128+
return IWL_RATE_INVALID;
129129
}
130130

131131
static void rs_rate_scale_perform(struct iwl_priv *priv,
@@ -3146,7 +3146,10 @@ static ssize_t rs_sta_dbgfs_scale_table_read(struct file *file,
31463146
for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) {
31473147
index = iwl_hwrate_to_plcp_idx(
31483148
le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags));
3149-
if (is_legacy(tbl->lq_type)) {
3149+
if (index == IWL_RATE_INVALID) {
3150+
desc += sprintf(buff + desc, " rate[%d] 0x%X invalid rate\n",
3151+
i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags));
3152+
} else if (is_legacy(tbl->lq_type)) {
31503153
desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n",
31513154
i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags),
31523155
iwl_rate_mcs[index].mbps);

drivers/net/wireless/intel/iwlwifi/mvm/rs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,10 +1072,13 @@ static void rs_get_lower_rate_down_column(struct iwl_lq_sta *lq_sta,
10721072

10731073
rate->bw = RATE_MCS_CHAN_WIDTH_20;
10741074

1075-
WARN_ON_ONCE(rate->index < IWL_RATE_MCS_0_INDEX ||
1076-
rate->index > IWL_RATE_MCS_9_INDEX);
1075+
if (WARN_ON_ONCE(rate->index < IWL_RATE_MCS_0_INDEX))
1076+
rate->index = rs_ht_to_legacy[IWL_RATE_MCS_0_INDEX];
1077+
else if (WARN_ON_ONCE(rate->index > IWL_RATE_MCS_9_INDEX))
1078+
rate->index = rs_ht_to_legacy[IWL_RATE_MCS_9_INDEX];
1079+
else
1080+
rate->index = rs_ht_to_legacy[rate->index];
10771081

1078-
rate->index = rs_ht_to_legacy[rate->index];
10791082
rate->ldpc = false;
10801083
} else {
10811084
/* Downgrade to SISO with same MCS if in MIMO */

0 commit comments

Comments
 (0)