diff mbox

[v2] mac80211: allow not sending MIC up from driver for HW crypto

Message ID 1456259474-1370-1-git-send-email-emmanuel.grumbach@intel.com
State Changes Requested
Delegated to: Johannes Berg
Headers show

Commit Message

Emmanuel Grumbach Feb. 23, 2016, 8:31 p.m. UTC
From: Sara Sharon <sara.sharon@intel.com>

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 <sara.sharon@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
---
 include/net/mac80211.h |  5 ++++-
 net/mac80211/util.c    |  5 +++--
 net/mac80211/wpa.c     | 26 ++++++++++++++------------
 3 files changed, 21 insertions(+), 15 deletions(-)

Comments

kernel test robot Feb. 23, 2016, 10:22 p.m. UTC | #1
Hi Sara,

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on v4.5-rc5 next-20160223]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Emmanuel-Grumbach/mac80211-allow-not-sending-MIC-up-from-driver-for-HW-crypto/20160224-043311
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: x86_64-allmodconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/net/wireless/ath/ath10k/htt_rx.c: In function 'ath10k_process_rx':
>> drivers/net/wireless/ath/ath10k/htt_rx.c:982:6: warning: format '%x' expects argument of type 'unsigned int', but argument 20 has type 'u64 {aka long long unsigned int}' [-Wformat=]
         "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",
         ^
--
   In file included from include/linux/printk.h:6:0,
                    from include/linux/kernel.h:13,
                    from include/linux/skbuff.h:17,
                    from include/linux/if_ether.h:23,
                    from include/linux/etherdevice.h:25,
                    from drivers/net/wireless/ath/wcn36xx/txrx.h:20,
                    from drivers/net/wireless/ath/wcn36xx/txrx.c:19:
   drivers/net/wireless/ath/wcn36xx/txrx.c: In function 'wcn36xx_rx_skb':
>> include/linux/kern_levels.h:4:18: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'u64 {aka long long unsigned int}' [-Wformat=]
    #define KERN_SOH "\001"  /* ASCII Start Of Header */
                     ^
   include/linux/kern_levels.h:14:20: note: in expansion of macro 'KERN_SOH'
    #define KERN_DEBUG KERN_SOH "7" /* debug-level messages */
                       ^
>> drivers/net/wireless/ath/wcn36xx/wcn36xx.h:70:10: note: in expansion of macro 'KERN_DEBUG'
      printk(KERN_DEBUG pr_fmt(fmt), ##arg); \
             ^
>> drivers/net/wireless/ath/wcn36xx/txrx.c:60:2: note: in expansion of macro 'wcn36xx_dbg'
     wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%x\n", status.flag);
     ^

vim +982 drivers/net/wireless/ath/ath10k/htt_rx.c

76f5329a Janusz Dziedzic 2014-07-28  966  
76f5329a Janusz Dziedzic 2014-07-28  967  	return out;
76f5329a Janusz Dziedzic 2014-07-28  968  }
76f5329a Janusz Dziedzic 2014-07-28  969  
85f6d7cf Janusz Dziedzic 2014-03-24  970  static void ath10k_process_rx(struct ath10k *ar,
85f6d7cf Janusz Dziedzic 2014-03-24  971  			      struct ieee80211_rx_status *rx_status,
85f6d7cf Janusz Dziedzic 2014-03-24  972  			      struct sk_buff *skb)
73539b40 Janusz Dziedzic 2014-03-24  973  {
73539b40 Janusz Dziedzic 2014-03-24  974  	struct ieee80211_rx_status *status;
76f5329a Janusz Dziedzic 2014-07-28  975  	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
76f5329a Janusz Dziedzic 2014-07-28  976  	char tid[32];
73539b40 Janusz Dziedzic 2014-03-24  977  
85f6d7cf Janusz Dziedzic 2014-03-24  978  	status = IEEE80211_SKB_RXCB(skb);
85f6d7cf Janusz Dziedzic 2014-03-24  979  	*status = *rx_status;
73539b40 Janusz Dziedzic 2014-03-24  980  
7aa7a72a Michal Kazior   2014-08-25  981  	ath10k_dbg(ar, ATH10K_DBG_DATA,
76f5329a Janusz Dziedzic 2014-07-28 @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",
85f6d7cf Janusz Dziedzic 2014-03-24  983  		   skb,
85f6d7cf Janusz Dziedzic 2014-03-24  984  		   skb->len,
76f5329a Janusz Dziedzic 2014-07-28  985  		   ieee80211_get_SA(hdr),
76f5329a Janusz Dziedzic 2014-07-28  986  		   ath10k_get_tid(hdr, tid, sizeof(tid)),
76f5329a Janusz Dziedzic 2014-07-28  987  		   is_multicast_ether_addr(ieee80211_get_DA(hdr)) ?
76f5329a Janusz Dziedzic 2014-07-28  988  							"mcast" : "ucast",
76f5329a Janusz Dziedzic 2014-07-28  989  		   (__le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4,
73539b40 Janusz Dziedzic 2014-03-24  990  		   status->flag == 0 ? "legacy" : "",

:::::: The code at line 982 was first introduced by commit
:::::: 76f5329a3dfe2f95dcc5664db603a2f1b0c9b825 ath10k: extend debug code for RX path

:::::: TO: Janusz Dziedzic <janusz.dziedzic@tieto.com>
:::::: CC: Kalle Valo <kvalo@qca.qualcomm.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Feb. 24, 2016, 7:02 a.m. UTC | #2
Hi Sara,

[auto build test WARNING on mac80211-next/master]
[also build test WARNING on v4.5-rc5 next-20160223]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Emmanuel-Grumbach/mac80211-allow-not-sending-MIC-up-from-driver-for-HW-crypto/20160224-043311
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master
config: i386-allyesconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/net/wireless/ath/wcn36xx/txrx.c: In function 'wcn36xx_rx_skb':
>> drivers/net/wireless/ath/wcn36xx/txrx.c:60:53: warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'u64 {aka long long unsigned int}' [-Wformat=]
     wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%x\n", status.flag);
                                                        ^

vim +60 drivers/net/wireless/ath/wcn36xx/txrx.c

8e84c258 Eugene Krasnikov  2013-10-08  44  
8e84c258 Eugene Krasnikov  2013-10-08  45  	skb_put(skb, bd->pdu.mpdu_header_off + bd->pdu.mpdu_len);
8e84c258 Eugene Krasnikov  2013-10-08  46  	skb_pull(skb, bd->pdu.mpdu_header_off);
8e84c258 Eugene Krasnikov  2013-10-08  47  
8e84c258 Eugene Krasnikov  2013-10-08  48  	status.mactime = 10;
8e84c258 Eugene Krasnikov  2013-10-08  49  	status.freq = WCN36XX_CENTER_FREQ(wcn);
8e84c258 Eugene Krasnikov  2013-10-08  50  	status.band = WCN36XX_BAND(wcn);
8e84c258 Eugene Krasnikov  2013-10-08  51  	status.signal = -get_rssi0(bd);
8e84c258 Eugene Krasnikov  2013-10-08  52  	status.antenna = 1;
8e84c258 Eugene Krasnikov  2013-10-08  53  	status.rate_idx = 1;
8e84c258 Eugene Krasnikov  2013-10-08  54  	status.flag = 0;
8e84c258 Eugene Krasnikov  2013-10-08  55  	status.rx_flags = 0;
8e84c258 Eugene Krasnikov  2013-10-08  56  	status.flag |= RX_FLAG_IV_STRIPPED |
8e84c258 Eugene Krasnikov  2013-10-08  57  		       RX_FLAG_MMIC_STRIPPED |
8e84c258 Eugene Krasnikov  2013-10-08  58  		       RX_FLAG_DECRYPTED;
8e84c258 Eugene Krasnikov  2013-10-08  59  
0059b2b1 Emmanuel Grumbach 2014-02-05 @60  	wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%x\n", status.flag);
8e84c258 Eugene Krasnikov  2013-10-08  61  
8e84c258 Eugene Krasnikov  2013-10-08  62  	memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
8e84c258 Eugene Krasnikov  2013-10-08  63  
8e84c258 Eugene Krasnikov  2013-10-08  64  	hdr = (struct ieee80211_hdr *) skb->data;
8e84c258 Eugene Krasnikov  2013-10-08  65  	fc = __le16_to_cpu(hdr->frame_control);
8e84c258 Eugene Krasnikov  2013-10-08  66  	sn = IEEE80211_SEQ_TO_SN(__le16_to_cpu(hdr->seq_ctrl));
8e84c258 Eugene Krasnikov  2013-10-08  67  
8e84c258 Eugene Krasnikov  2013-10-08  68  	if (ieee80211_is_beacon(hdr->frame_control)) {

:::::: The code at line 60 was first introduced by commit
:::::: 0059b2b142b9938118e1ed1ea630c527119425fe mac80211: remove unused radiotap vendor fields in ieee80211_rx_status

:::::: TO: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
:::::: CC: Johannes Berg <johannes.berg@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 0c09da3..9cf92d0 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1034,6 +1034,8 @@  ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info)
  *	on this subframe
  * @RX_FLAG_AMPDU_DELIM_CRC_KNOWN: The delimiter CRC field is known (the CRC
  *	is stored in the @ampdu_delimiter_crc field)
+ * @RX_FLAG_MIC_STRIPPED: The mic was stripped of this packet. Decryption was
+ *	done by the hardware
  * @RX_FLAG_LDPC: LDPC was used
  * @RX_FLAG_ONLY_MONITOR: Report frame only to monitor interfaces without
  *	processing it in any regular way.
@@ -1091,6 +1093,7 @@  enum mac80211_rx_flags {
 	RX_FLAG_5MHZ			= BIT(29),
 	RX_FLAG_AMSDU_MORE		= BIT(30),
 	RX_FLAG_RADIOTAP_VENDOR_DATA	= BIT(31),
+	RX_FLAG_MIC_STRIPPED            = BIT_ULL(32),
 };
 
 #define RX_FLAG_STBC_SHIFT		26
@@ -1148,7 +1151,7 @@  struct ieee80211_rx_status {
 	u64 mactime;
 	u32 device_timestamp;
 	u32 ampdu_reference;
-	u32 flag;
+	u64 flag;
 	u16 freq;
 	u8 vht_flag;
 	u8 rate_idx;
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 89f7179..743265a 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2714,8 +2714,9 @@  u64 ieee80211_calculate_rx_timestamp(struct ieee80211_local *local,
 
 	rate = cfg80211_calculate_bitrate(&ri);
 	if (WARN_ONCE(!rate,
-		      "Invalid bitrate: flags=0x%x, idx=%d, vht_nss=%d\n",
-		      status->flag, status->rate_idx, status->vht_nss))
+		      "Invalid bitrate: flags=0x%llx, idx=%d, vht_nss=%d\n",
+		      (unsigned long long)status->flag, status->rate_idx,
+		      status->vht_nss))
 		return 0;
 
 	/* rewind from end of MPDU */
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 1884825..7e4f265 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -504,18 +504,20 @@  ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx,
 	    !ieee80211_is_robust_mgmt_frame(skb))
 		return RX_CONTINUE;
 
-	data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len;
-	if (!rx->sta || data_len < 0)
-		return RX_DROP_UNUSABLE;
-
 	if (status->flag & RX_FLAG_DECRYPTED) {
 		if (!pskb_may_pull(rx->skb, hdrlen + IEEE80211_CCMP_HDR_LEN))
 			return RX_DROP_UNUSABLE;
+		if (status->flag & RX_FLAG_MIC_STRIPPED)
+			mic_len = 0;
 	} else {
 		if (skb_linearize(rx->skb))
 			return RX_DROP_UNUSABLE;
 	}
 
+	data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - mic_len;
+	if (!rx->sta || data_len < 0)
+		return RX_DROP_UNUSABLE;
+
 	if (!(status->flag & RX_FLAG_PN_VALIDATED)) {
 		ccmp_hdr2pn(pn, skb->data + hdrlen);
 
@@ -720,8 +722,7 @@  ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
 	struct sk_buff *skb = rx->skb;
 	struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
 	u8 pn[IEEE80211_GCMP_PN_LEN];
-	int data_len;
-	int queue;
+	int data_len, queue, mic_len = IEEE80211_GCMP_MIC_LEN;
 
 	hdrlen = ieee80211_hdrlen(hdr->frame_control);
 
@@ -729,19 +730,20 @@  ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
 	    !ieee80211_is_robust_mgmt_frame(skb))
 		return RX_CONTINUE;
 
-	data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN -
-		   IEEE80211_GCMP_MIC_LEN;
-	if (!rx->sta || data_len < 0)
-		return RX_DROP_UNUSABLE;
-
 	if (status->flag & RX_FLAG_DECRYPTED) {
 		if (!pskb_may_pull(rx->skb, hdrlen + IEEE80211_GCMP_HDR_LEN))
 			return RX_DROP_UNUSABLE;
+		if (status->flag & RX_FLAG_MIC_STRIPPED)
+			mic_len = 0;
 	} else {
 		if (skb_linearize(rx->skb))
 			return RX_DROP_UNUSABLE;
 	}
 
+	data_len = skb->len - hdrlen - IEEE80211_GCMP_HDR_LEN - mic_len;
+	if (!rx->sta || data_len < 0)
+		return RX_DROP_UNUSABLE;
+
 	if (!(status->flag & RX_FLAG_PN_VALIDATED)) {
 		gcmp_hdr2pn(pn, skb->data + hdrlen);
 
@@ -772,7 +774,7 @@  ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
 	}
 
 	/* Remove GCMP header and MIC */
-	if (pskb_trim(skb, skb->len - IEEE80211_GCMP_MIC_LEN))
+	if (pskb_trim(skb, skb->len - mic_len))
 		return RX_DROP_UNUSABLE;
 	memmove(skb->data + IEEE80211_GCMP_HDR_LEN, skb->data, hdrlen);
 	skb_pull(skb, IEEE80211_GCMP_HDR_LEN);