Skip to content

Commit 40a0b38

Browse files
ilanpeer2lucacoelho
authored andcommitted
iwlwifi: mvm: Fix calculation of frame length
The RADA might include in the Rx frame the MIC and CRC bytes. These bytes should be removed for non monitor interfaces and should not be passed to mac80211. Fix the Rx processing to remove the extra bytes on non monitor cases. Signed-off-by: Ilan Peer <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Link: https://lore.kernel.org/r/iwlwifi.20211219121514.098be12c801e.I1d81733d8a75b84c3b20eb6e0d14ab3405ca6a86@changeid Signed-off-by: Luca Coelho <[email protected]>
1 parent 998e1ab commit 40a0b38

File tree

1 file changed

+27
-0
lines changed
  • drivers/net/wireless/intel/iwlwifi/mvm

1 file changed

+27
-0
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,39 @@ static int iwl_mvm_create_skb(struct iwl_mvm *mvm, struct sk_buff *skb,
121121
struct iwl_rx_mpdu_desc *desc = (void *)pkt->data;
122122
unsigned int headlen, fraglen, pad_len = 0;
123123
unsigned int hdrlen = ieee80211_hdrlen(hdr->frame_control);
124+
u8 mic_crc_len = u8_get_bits(desc->mac_flags1,
125+
IWL_RX_MPDU_MFLG1_MIC_CRC_LEN_MASK) << 1;
124126

125127
if (desc->mac_flags2 & IWL_RX_MPDU_MFLG2_PAD) {
126128
len -= 2;
127129
pad_len = 2;
128130
}
129131

132+
/*
133+
* For non monitor interface strip the bytes the RADA might not have
134+
* removed. As monitor interface cannot exist with other interfaces
135+
* this removal is safe.
136+
*/
137+
if (mic_crc_len && !ieee80211_hw_check(mvm->hw, RX_INCLUDES_FCS)) {
138+
u32 pkt_flags = le32_to_cpu(pkt->len_n_flags);
139+
140+
/*
141+
* If RADA was not enabled then decryption was not performed so
142+
* the MIC cannot be removed.
143+
*/
144+
if (!(pkt_flags & FH_RSCSR_RADA_EN)) {
145+
if (WARN_ON(crypt_len > mic_crc_len))
146+
return -EINVAL;
147+
148+
mic_crc_len -= crypt_len;
149+
}
150+
151+
if (WARN_ON(mic_crc_len > len))
152+
return -EINVAL;
153+
154+
len -= mic_crc_len;
155+
}
156+
130157
/* If frame is small enough to fit in skb->head, pull it completely.
131158
* If not, only pull ieee80211_hdr (including crypto if present, and
132159
* an additional 8 bytes for SNAP/ethertype, see below) so that

0 commit comments

Comments
 (0)