Skip to content

Commit f980ebc

Browse files
sara-sjmberg-intel
authored andcommitted
mac80211: allow not sending MIC up from driver for HW crypto
When HW crypto is used, there's no need for the CCMP/GCMP MIC to be available to mac80211, and the hardware might have removed it already after checking. The MIC is also useless to have when the frame is already decrypted, so allow indicating that it's not present. Since we are running out of bits in mac80211_rx_flags, make the flags field a u64. Signed-off-by: Sara Sharon <[email protected]> Signed-off-by: Emmanuel Grumbach <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent 162dd6a commit f980ebc

File tree

5 files changed

+23
-17
lines changed

5 files changed

+23
-17
lines changed

drivers/net/wireless/ath/ath10k/htt_rx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ static void ath10k_process_rx(struct ath10k *ar,
979979
*status = *rx_status;
980980

981981
ath10k_dbg(ar, ATH10K_DBG_DATA,
982-
"rx skb %p len %u peer %pM %s %s sn %u %s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %i mic-err %i amsdu-more %i\n",
982+
"rx skb %p len %u peer %pM %s %s sn %u %s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%llx fcs-err %i mic-err %i amsdu-more %i\n",
983983
skb,
984984
skb->len,
985985
ieee80211_get_SA(hdr),

drivers/net/wireless/ath/wcn36xx/txrx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb)
5757
RX_FLAG_MMIC_STRIPPED |
5858
RX_FLAG_DECRYPTED;
5959

60-
wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%x\n", status.flag);
60+
wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%llx\n", status.flag);
6161

6262
memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
6363

include/net/mac80211.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,8 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
10341034
* on this subframe
10351035
* @RX_FLAG_AMPDU_DELIM_CRC_KNOWN: The delimiter CRC field is known (the CRC
10361036
* is stored in the @ampdu_delimiter_crc field)
1037+
* @RX_FLAG_MIC_STRIPPED: The mic was stripped of this packet. Decryption was
1038+
* done by the hardware
10371039
* @RX_FLAG_LDPC: LDPC was used
10381040
* @RX_FLAG_ONLY_MONITOR: Report frame only to monitor interfaces without
10391041
* processing it in any regular way.
@@ -1091,6 +1093,7 @@ enum mac80211_rx_flags {
10911093
RX_FLAG_5MHZ = BIT(29),
10921094
RX_FLAG_AMSDU_MORE = BIT(30),
10931095
RX_FLAG_RADIOTAP_VENDOR_DATA = BIT(31),
1096+
RX_FLAG_MIC_STRIPPED = BIT_ULL(32),
10941097
};
10951098

10961099
#define RX_FLAG_STBC_SHIFT 26
@@ -1151,7 +1154,7 @@ struct ieee80211_rx_status {
11511154
u64 boottime_ns;
11521155
u32 device_timestamp;
11531156
u32 ampdu_reference;
1154-
u32 flag;
1157+
u64 flag;
11551158
u16 freq;
11561159
u8 vht_flag;
11571160
u8 rate_idx;

net/mac80211/util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,8 +2724,9 @@ u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
27242724

27252725
rate = cfg80211_calculate_bitrate(&ri);
27262726
if (WARN_ONCE(!rate,
2727-
"Invalid bitrate: flags=0x%x, idx=%d, vht_nss=%d\n",
2728-
status->flag, status->rate_idx, status->vht_nss))
2727+
"Invalid bitrate: flags=0x%llx, idx=%d, vht_nss=%d\n",
2728+
(unsigned long long)status->flag, status->rate_idx,
2729+
status->vht_nss))
27292730
return 0;
27302731

27312732
/* rewind from end of MPDU */

net/mac80211/wpa.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,20 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx,
504504
!ieee80211_is_robust_mgmt_frame(skb))
505505
return RX_CONTINUE;
506506

507-
data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len;
508-
if (!rx->sta || data_len < 0)
509-
return RX_DROP_UNUSABLE;
510-
511507
if (status->flag & RX_FLAG_DECRYPTED) {
512508
if (!pskb_may_pull(rx->skb, hdrlen + IEEE80211_CCMP_HDR_LEN))
513509
return RX_DROP_UNUSABLE;
510+
if (status->flag & RX_FLAG_MIC_STRIPPED)
511+
mic_len = 0;
514512
} else {
515513
if (skb_linearize(rx->skb))
516514
return RX_DROP_UNUSABLE;
517515
}
518516

517+
data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len;
518+
if (!rx->sta || data_len < 0)
519+
return RX_DROP_UNUSABLE;
520+
519521
if (!(status->flag & RX_FLAG_PN_VALIDATED)) {
520522
ccmp_hdr2pn(pn, skb->data + hdrlen);
521523

@@ -720,28 +722,28 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
720722
struct sk_buff *skb = rx->skb;
721723
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
722724
u8 pn[IEEE80211_GCMP_PN_LEN];
723-
int data_len;
724-
int queue;
725+
int data_len, queue, mic_len = IEEE80211_GCMP_MIC_LEN;
725726

726727
hdrlen = ieee80211_hdrlen(hdr->frame_control);
727728

728729
if (!ieee80211_is_data(hdr->frame_control) &&
729730
!ieee80211_is_robust_mgmt_frame(skb))
730731
return RX_CONTINUE;
731732

732-
data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN -
733-
IEEE80211_GCMP_MIC_LEN;
734-
if (!rx->sta || data_len < 0)
735-
return RX_DROP_UNUSABLE;
736-
737733
if (status->flag & RX_FLAG_DECRYPTED) {
738734
if (!pskb_may_pull(rx->skb, hdrlen + IEEE80211_GCMP_HDR_LEN))
739735
return RX_DROP_UNUSABLE;
736+
if (status->flag & RX_FLAG_MIC_STRIPPED)
737+
mic_len = 0;
740738
} else {
741739
if (skb_linearize(rx->skb))
742740
return RX_DROP_UNUSABLE;
743741
}
744742

743+
data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN - mic_len;
744+
if (!rx->sta || data_len < 0)
745+
return RX_DROP_UNUSABLE;
746+
745747
if (!(status->flag & RX_FLAG_PN_VALIDATED)) {
746748
gcmp_hdr2pn(pn, skb->data + hdrlen);
747749

@@ -772,7 +774,7 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
772774
}
773775

774776
/* Remove GCMP header and MIC */
775-
if (pskb_trim(skb, skb->len - IEEE80211_GCMP_MIC_LEN))
777+
if (pskb_trim(skb, skb->len - mic_len))
776778
return RX_DROP_UNUSABLE;
777779
memmove(skb->data + IEEE80211_GCMP_HDR_LEN, skb->data, hdrlen);
778780
skb_pull(skb, IEEE80211_GCMP_HDR_LEN);

0 commit comments

Comments
 (0)