Skip to content

Commit

Permalink
iwlwifi: mvm: debugfs: check length precisely in inject_packet
Browse files Browse the repository at this point in the history
When we check the length, we only check that the advertised
data length fits into the data we have, but currently not
that it actually matches correctly.

This should be harmless, but if the first two bytes are zero,
then the iwl_rx_packet_payload_len() ends up negative, and
that might later cause issues if unsigned variables are used,
as this is not something that's normally expected.

Change the validation here to precisely validate the lengths
match, to avoid such issues.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210117164916.5184dfc2a445.I0631d2e4f6ffb93cf06618edb035c45bd6d1d7b9@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
  • Loading branch information
Johannes Berg authored and Luca Coelho committed Feb 5, 2021
1 parent 9aae43a commit 5c255a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,9 +1169,9 @@ static ssize_t iwl_dbgfs_inject_packet_write(struct iwl_mvm *mvm,
if (ret)
goto out;

/* avoid invalid memory access */
/* avoid invalid memory access and malformed packet */
if (bin_len < sizeof(*pkt) ||
bin_len < sizeof(*pkt) + iwl_rx_packet_payload_len(pkt))
bin_len != sizeof(*pkt) + iwl_rx_packet_payload_len(pkt))
goto out;

local_bh_disable();
Expand Down

0 comments on commit 5c255a1

Please sign in to comment.