From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org,
Liad Kaufman <liad.kaufman@intel.com>,
Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH 11/16] iwlwifi: tighten boundary checks
Date: Mon, 21 Jan 2019 09:50:21 +0200 [thread overview]
Message-ID: <20190121075026.25059-12-luca@coelho.fi> (raw)
In-Reply-To: <20190121075026.25059-1-luca@coelho.fi>
From: Liad Kaufman <liad.kaufman@intel.com>
The driver assumes certain sizes and lengths aren't crossed in some
places. Make sure this indeed happens.
Found by Klocwork.
Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 2 ++
drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 24 +++++++++++++++----
.../net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 6 ++++-
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
index 5f16879ab26a..56e99b5661f7 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c
@@ -835,6 +835,8 @@ _iwl_fw_error_dump(struct iwl_fw_runtime *fwrt,
if (!fwrt->trans->cfg->dccm_offset || !fwrt->trans->cfg->dccm_len) {
const struct fw_img *img;
+ if (fwrt->cur_fw_img >= IWL_UCODE_TYPE_MAX)
+ return NULL;
img = &fwrt->fw->img[fwrt->cur_fw_img];
sram_ofs = img->sec[IWL_UCODE_SECTION_DATA].offset;
sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
index 2adef6e3e0ac..ac62eb8c4b36 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
@@ -1024,7 +1024,12 @@ static void iwl_mvm_tx_airtime(struct iwl_mvm *mvm,
int airtime)
{
int mac = mvmsta->mac_id_n_color & FW_CTXT_ID_MSK;
- struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac];
+ struct iwl_mvm_tcm_mac *mdata;
+
+ if (mac >= NUM_MAC_INDEX_DRIVER)
+ return;
+
+ mdata = &mvm->tcm.data[mac];
if (mvm->tcm.paused)
return;
@@ -1035,14 +1040,21 @@ static void iwl_mvm_tx_airtime(struct iwl_mvm *mvm,
mdata->tx.airtime += airtime;
}
-static void iwl_mvm_tx_pkt_queued(struct iwl_mvm *mvm,
- struct iwl_mvm_sta *mvmsta, int tid)
+static int iwl_mvm_tx_pkt_queued(struct iwl_mvm *mvm,
+ struct iwl_mvm_sta *mvmsta, int tid)
{
u32 ac = tid_to_mac80211_ac[tid];
int mac = mvmsta->mac_id_n_color & FW_CTXT_ID_MSK;
- struct iwl_mvm_tcm_mac *mdata = &mvm->tcm.data[mac];
+ struct iwl_mvm_tcm_mac *mdata;
+
+ if (mac >= NUM_MAC_INDEX_DRIVER)
+ return -EINVAL;
+
+ mdata = &mvm->tcm.data[mac];
mdata->tx.pkts[ac]++;
+
+ return 0;
}
/*
@@ -1162,7 +1174,9 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,
spin_unlock(&mvmsta->lock);
- iwl_mvm_tx_pkt_queued(mvm, mvmsta, tid == IWL_MAX_TID_COUNT ? 0 : tid);
+ if (iwl_mvm_tx_pkt_queued(mvm, mvmsta,
+ tid == IWL_MAX_TID_COUNT ? 0 : tid))
+ goto drop;
return 0;
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
index 156ca1b1f621..af2791502b7d 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c
@@ -214,7 +214,11 @@ static int iwl_pcie_gen2_set_tb(struct iwl_trans *trans,
{
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
int idx = iwl_pcie_gen2_get_num_tbs(trans, tfd);
- struct iwl_tfh_tb *tb = &tfd->tbs[idx];
+ struct iwl_tfh_tb *tb;
+
+ if (WARN_ON(idx >= IWL_NUM_OF_TBS))
+ return -EINVAL;
+ tb = &tfd->tbs[idx];
/* Each TFD can point to a maximum max_tbs Tx buffers */
if (le16_to_cpu(tfd->num_tbs) >= trans_pcie->max_tbs) {
--
2.20.1
next prev parent reply other threads:[~2019-01-21 7:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-21 7:50 [PATCH 00/16] iwlwifi: updates intended for v4.21 2019-01-21 Luca Coelho
2019-01-21 7:50 ` [PATCH 01/16] iwlwifi: mvm: support mac80211 AMSDU Luca Coelho
2019-01-22 12:53 ` Kalle Valo
2019-01-23 8:25 ` [PATCH v2] " Luca Coelho
2019-01-21 7:50 ` [PATCH 02/16] iwlwifi: mvm: fix values in the table example Luca Coelho
2019-01-21 7:50 ` [PATCH 03/16] iwlwifi: use kmemdup in iwl_parse_nvm_mcc_info() Luca Coelho
2019-01-21 7:50 ` [PATCH 04/16] iwlwifi: fix spelling mistake "registrating" -> "registering" Luca Coelho
2019-01-21 7:50 ` [PATCH 05/16] iwlwifi: mvm: bring back mvm GSO code Luca Coelho
2019-01-21 7:50 ` [PATCH 06/16] iwlwifi: mvm: Flush transmit queues on P2P Device ROC done Luca Coelho
2019-01-21 7:50 ` [PATCH 07/16] iwlwifi: mvm: Set Tx rate and flags when there is not station Luca Coelho
2019-01-21 7:50 ` [PATCH 08/16] iwlwifi: mvm: Do not set RTS/CTS protection for P2P Device MAC Luca Coelho
2019-01-21 7:50 ` [PATCH 09/16] iwlwifi: update hcmds documentation Luca Coelho
2019-01-21 7:50 ` [PATCH 10/16] iwlwifi: mvm: make num_active_macs unsigned Luca Coelho
2019-01-21 7:50 ` Luca Coelho [this message]
2019-01-21 7:50 ` [PATCH 12/16] iwlwifi: memcpy from dev_cmd and not dev_cmd->hdr Luca Coelho
2019-01-21 7:50 ` [PATCH 13/16] iwlwifi: mvm: avoid possible access out of array Luca Coelho
2019-01-21 7:50 ` [PATCH 14/16] iwlwifi: avoid access out of memory allocated Luca Coelho
2019-01-21 7:50 ` [PATCH 15/16] iwlwifi: fw api: remove unused/deprecated filter status Luca Coelho
2019-01-21 7:50 ` [PATCH 16/16] iwlwifi: fw api: document WoWLAN patterns command Luca Coelho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190121075026.25059-12-luca@coelho.fi \
--to=luca@coelho.fi \
--cc=kvalo@codeaurora.org \
--cc=liad.kaufman@intel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=luciano.coelho@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).