summaryrefslogtreecommitdiffstats
path: root/net/wireless
diff options
context:
space:
mode:
authorMasashi Honma <masashi.honma@gmail.com>2019-09-07 20:56:53 -0400
committerJohannes Berg <johannes.berg@intel.com>2019-09-11 03:33:29 -0400
commit4b2c5a14cd8005a900075f7dfec87473c6ee66fb (patch)
tree08c2e1322322e48c7be418f9eec450f3730b4c0e /net/wireless
parent06354665f92fa8be36124a8ba7113cdfa40d9df5 (diff)
nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds
commit 1222a1601488 ("nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds") was incomplete and requires one more fix to prevent accessing to rssi_thresholds[n] because user can control rssi_thresholds[i] values to make i reach to n. For example, rssi_thresholds = {-400, -300, -200, -100} when last is -34. Cc: stable@vger.kernel.org Fixes: 1222a1601488 ("nl80211: Fix possible Spectre-v1 for CQM RSSI thresholds") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Masashi Honma <masashi.honma@gmail.com> Link: https://lore.kernel.org/r/20190908005653.17433-1-masashi.honma@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless')
-rw-r--r--net/wireless/nl80211.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 0c7fa6004ffb..d21b1581a665 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -10805,9 +10805,11 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
10805 hyst = wdev->cqm_config->rssi_hyst; 10805 hyst = wdev->cqm_config->rssi_hyst;
10806 n = wdev->cqm_config->n_rssi_thresholds; 10806 n = wdev->cqm_config->n_rssi_thresholds;
10807 10807
10808 for (i = 0; i < n; i++) 10808 for (i = 0; i < n; i++) {
10809 i = array_index_nospec(i, n);
10809 if (last < wdev->cqm_config->rssi_thresholds[i]) 10810 if (last < wdev->cqm_config->rssi_thresholds[i])
10810 break; 10811 break;
10812 }
10811 10813
10812 low_index = i - 1; 10814 low_index = i - 1;
10813 if (low_index >= 0) { 10815 if (low_index >= 0) {