Commit 08326a97 authored by Johannes Berg's avatar Johannes Berg Committed by Luca Coelho

iwlwifi: pcie: fix indexing in command dump for new HW

We got a crash in iwl_trans_pcie_get_cmdlen(), while the TFD was
being accessed to sum up the lengths.

We want to access the TFD here, which is the information for the
hardware. We always only allocate 32 buffers for the cmd queue,
but on newer hardware (using TFH) we can also allocate only a
shorter hardware array, also only 32 TFDs. Prior to the TFH, we
had to allocate a bigger TFD array but would make those point to
a smaller set of buffers.

Additionally, now max_tfd_queue_size is up to 65536, so we can
access *way* out of bounds of a really only 32-entry array, so
it crashes.

Fix this by making the TFD index depend on which hardware we are
using right now.

While changing the calculation, also fix it to not use void ptr
arithmetic, but cast to u8 * before.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent a2113cc4
...@@ -3272,11 +3272,17 @@ static struct iwl_trans_dump_data ...@@ -3272,11 +3272,17 @@ static struct iwl_trans_dump_data
ptr = cmdq->write_ptr; ptr = cmdq->write_ptr;
for (i = 0; i < cmdq->n_window; i++) { for (i = 0; i < cmdq->n_window; i++) {
u8 idx = iwl_pcie_get_cmd_index(cmdq, ptr); u8 idx = iwl_pcie_get_cmd_index(cmdq, ptr);
u8 tfdidx;
u32 caplen, cmdlen; u32 caplen, cmdlen;
if (trans->trans_cfg->use_tfh)
tfdidx = idx;
else
tfdidx = ptr;
cmdlen = iwl_trans_pcie_get_cmdlen(trans, cmdlen = iwl_trans_pcie_get_cmdlen(trans,
cmdq->tfds + (u8 *)cmdq->tfds +
tfd_size * ptr); tfd_size * tfdidx);
caplen = min_t(u32, TFD_MAX_PAYLOAD_SIZE, cmdlen); caplen = min_t(u32, TFD_MAX_PAYLOAD_SIZE, cmdlen);
if (cmdlen) { if (cmdlen) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment