linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
To: linux-wireless@vger.kernel.org
Cc: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH 20/31] iwlwifi: check the size of the trigger struct from the firmware file
Date: Thu,  2 Apr 2015 09:41:08 +0300	[thread overview]
Message-ID: <1427956879-11725-20-git-send-email-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <1427956656.8122.2.camel@egrumbacBox>

When we access the triggers we need to make sure that the
data we expect was actually provided by the firmware file.
Check this when we decode the triggers from the firmware
file.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 drivers/net/wireless/iwlwifi/iwl-drv.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index 885c787..b8e5690 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -1102,6 +1102,7 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
 	const unsigned int api_max = drv->cfg->ucode_api_max;
 	unsigned int api_ok = drv->cfg->ucode_api_ok;
 	const unsigned int api_min = drv->cfg->ucode_api_min;
+	size_t trigger_tlv_sz[FW_DBG_TRIGGER_MAX];
 	u32 api_ver;
 	int i;
 	bool load_module = false;
@@ -1221,8 +1222,35 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
 		}
 	}
 
+	memset(&trigger_tlv_sz, 0xff, sizeof(trigger_tlv_sz));
+
+	trigger_tlv_sz[FW_DBG_TRIGGER_MISSED_BEACONS] =
+		sizeof(struct iwl_fw_dbg_trigger_missed_bcon);
+	trigger_tlv_sz[FW_DBG_TRIGGER_CHANNEL_SWITCH] = 0;
+	trigger_tlv_sz[FW_DBG_TRIGGER_FW_NOTIF] =
+		sizeof(struct iwl_fw_dbg_trigger_cmd);
+	trigger_tlv_sz[FW_DBG_TRIGGER_MLME] =
+		sizeof(struct iwl_fw_dbg_trigger_mlme);
+	trigger_tlv_sz[FW_DBG_TRIGGER_STATS] =
+		sizeof(struct iwl_fw_dbg_trigger_stats);
+	trigger_tlv_sz[FW_DBG_TRIGGER_RSSI] =
+		sizeof(struct iwl_fw_dbg_trigger_low_rssi);
+	trigger_tlv_sz[FW_DBG_TRIGGER_TXQ_TIMERS] =
+		sizeof(struct iwl_fw_dbg_trigger_txq_timer);
+
 	for (i = 0; i < ARRAY_SIZE(drv->fw.dbg_trigger_tlv); i++) {
 		if (pieces->dbg_trigger_tlv[i]) {
+			/*
+			 * If the trigger isn't long enough, WARN and exit.
+			 * Someone is trying to debug something and he won't
+			 * be able to catch the bug he is trying to chase.
+			 * We'd better be noisy to be sure he knows what's
+			 * going on.
+			 */
+			if (WARN_ON(pieces->dbg_trigger_tlv_len[i] <
+				    (trigger_tlv_sz[i] +
+				     sizeof(struct iwl_fw_dbg_trigger_tlv))))
+				goto out_free_fw;
 			drv->fw.dbg_trigger_tlv_len[i] =
 				pieces->dbg_trigger_tlv_len[i];
 			drv->fw.dbg_trigger_tlv[i] =
-- 
1.9.1


  parent reply	other threads:[~2015-04-02  6:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02  6:37 pull request: iwlwifi-next 2015-04-02 Grumbach, Emmanuel
2015-04-02  6:40 ` [PATCH 01/31] iwlwifi: mvm: continue (with error) CSA on GO time event failure Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 02/31] iwlwifi: mvm: assign new TLV bit for multi-source LAR Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 03/31] iwlwifi: pcie: add rx packet sequence number to dbg print Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 04/31] iwlwifi: mvm: properly flush the queues for buffering transport Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 05/31] iwlwifi: mvm: add iccm data to 8000 b-step data dump Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 06/31] iwlwifi: mvm: remove time-event start/end failure warning Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 07/31] iwlwifi: mvm: don't wait for firmware verification Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 08/31] iwlwifi: mvm: take IWL_MVM_REF_UCODE_DOWN before restarting hw Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 09/31] iwlwifi: mvm: remove d0i3 ref correctly during AP start Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 10/31] iwlwifi: mvm: inform mac80211 about umac scans that was aborted by restart Emmanuel Grumbach
2015-04-02  6:40 ` [PATCH 11/31] iwlwifi: pcie: initialize trans_pcie->ref_count on configure() Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 12/31] iwlwifi: mvm: add delay to scheduled scan Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 13/31] iwlwifi: mvm: use debugfs_create_bool() for enable_scan_iteration_notif Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 14/31] iwlwifi: drop support for early versions of 8000 Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 15/31] iwlwifi: mvm: allow to configure the timeout for the Tx queues Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 16/31] iwlwifi: mvm: fix debug print in the RSA ownership workaround Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 17/31] iwlwifi: 8000: change PNVM in case it doesn't match to the HW step Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 18/31] iwlwifi: mvm: Clean up UMAC scan UIDs in the reset and drv_stop flows Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 19/31] iwlwifi: mvm: rs: fix comment indentation Emmanuel Grumbach
2015-04-02  6:41 ` Emmanuel Grumbach [this message]
2015-04-02  6:41 ` [PATCH 21/31] iwlwifi: mvm: rs: refactor rs_update_rate_tbl Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 22/31] iwlwifi: mvm: add debugfs entry with the number of net-detect scans Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 23/31] iwlwifi: mvm: always reconfigure last MCC on init Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 24/31] iwlwifi: mvm: Fix wrongfully flushing frames in the roc/off channel queue Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 25/31] iwlwifi: mvm: remove unused arguments Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 26/31] iwlwifi: mvm: add trigger for firmware dump upon MLME failures Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 27/31] iwlwifi: mvm: don't return uninitialized value in get_survey() Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 28/31] iwlwifi: fix spelling errors Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 29/31] iwlwifi: mvm: do string formatting in debug triggers Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 30/31] iwlwifi: mvm: add trigger for time events Emmanuel Grumbach
2015-04-02  6:41 ` [PATCH 31/31] iwlwifi: mvm: capture connection loss as part of MLME trigger Emmanuel Grumbach
2015-04-07 17:06 ` pull request: iwlwifi-next 2015-04-02 Kalle Valo

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=1427956879-11725-20-git-send-email-emmanuel.grumbach@intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    /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).