aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Coelho <luciano.coelho@intel.com>2017-12-18 13:13:07 -0500
committerLuca Coelho <luciano.coelho@intel.com>2018-03-28 05:16:04 -0400
commit9a233bb8025105db9a60b5d761005cc5a6c77f3d (patch)
treeed659e1be50cea9fbd5529127075b9032f219b7e
parent759931c79fc3c8c4748269a5c2e7d48563baa6d5 (diff)
iwlwifi: mvm: check if mac80211_queue is valid in iwl_mvm_disable_txq
Sometimes iwl_mvm_disable_txq() may be called with mac80211_queue == IEEE80211_INVAL_HW_QUEUE, and this would cause us to use BIT(0xFF) which is way too large for the u16 we used to store it in hw_queue_to_mac820211. If this happens the following UBSAN warning will be generated: [ 167.185167] UBSAN: Undefined behaviour in drivers/net/wireless/intel/iwlwifi/mvm/utils.c:838:5 [ 167.185171] shift exponent 255 is too large for 64-bit type 'long unsigned int' Fix that by checking that it is not IEEE80211_INVAL_HW_QUEUE and, while at it, add a warning if the queue number is larger than IEEE80211_MAX_QUEUES. Fixes: 34e10860ae8d ("iwlwifi: mvm: remove references to queue_info in new TX path") Reported-by: Paul Menzel <pmenzel+linux-wireless@molgen.mpg.de> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/utils.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
index d65e1db7c097..70f8b8eb6117 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/utils.c
@@ -800,12 +800,19 @@ int iwl_mvm_disable_txq(struct iwl_mvm *mvm, int queue, int mac80211_queue,
800 .scd_queue = queue, 800 .scd_queue = queue,
801 .action = SCD_CFG_DISABLE_QUEUE, 801 .action = SCD_CFG_DISABLE_QUEUE,
802 }; 802 };
803 bool remove_mac_queue = true; 803 bool remove_mac_queue = mac80211_queue != IEEE80211_INVAL_HW_QUEUE;
804 int ret; 804 int ret;
805 805
806 if (WARN_ON(remove_mac_queue && mac80211_queue >= IEEE80211_MAX_QUEUES))
807 return -EINVAL;
808
806 if (iwl_mvm_has_new_tx_api(mvm)) { 809 if (iwl_mvm_has_new_tx_api(mvm)) {
807 spin_lock_bh(&mvm->queue_info_lock); 810 spin_lock_bh(&mvm->queue_info_lock);
808 mvm->hw_queue_to_mac80211[queue] &= ~BIT(mac80211_queue); 811
812 if (remove_mac_queue)
813 mvm->hw_queue_to_mac80211[queue] &=
814 ~BIT(mac80211_queue);
815
809 spin_unlock_bh(&mvm->queue_info_lock); 816 spin_unlock_bh(&mvm->queue_info_lock);
810 817
811 iwl_trans_txq_free(mvm->trans, queue); 818 iwl_trans_txq_free(mvm->trans, queue);