]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ath10k: Fill GCMP MIC length for PMF
authorYingying Tang <yintang@codeaurora.org>
Wed, 18 Mar 2020 14:15:11 +0000 (19:45 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Sun, 22 Mar 2020 10:22:01 +0000 (12:22 +0200)
GCMP MIC length is not filled for GCMP/GCMP-256 cipher suites in
PMF enabled case. Due to mismatch in MIC length, deauth/disassoc frames
are unencrypted.
This patch fills proper MIC length for GCMP/GCMP-256 cipher suites.

Tested HW: QCA9984, QCA9888
Tested FW: 10.4-3.6-00104

Signed-off-by: Yingying Tang <yintang@codeaurora.org>
Co-developed-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
Signed-off-by: Sowmiya Sree Elavalagan <ssreeela@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath10k/htt_tx.c
drivers/net/wireless/ath/ath10k/mac.c
drivers/net/wireless/ath/ath10k/wmi.c

index edf314e3e19e39dd4eb18c8ae1fcd48fae93ccd0..bd8ef576c5903e95ab1b01ce9d7ff4cb72662ca0 100644 (file)
@@ -119,6 +119,7 @@ struct ath10k_skb_cb {
        u16 airtime_est;
        struct ieee80211_vif *vif;
        struct ieee80211_txq *txq;
+       u32 ucast_cipher;
 } __packed;
 
 struct ath10k_skb_rxcb {
@@ -504,6 +505,7 @@ struct ath10k_sta {
        struct work_struct update_wk;
        u64 rx_duration;
        struct ath10k_htt_tx_stats *tx_stats;
+       u32 ucast_cipher;
 
 #ifdef CONFIG_MAC80211_DEBUGFS
        /* protected by conf_mutex */
index a182c0944cc76fa469fdaa134144a49ed9d5eae8..e9d12ea708b62615b92f78ee31da85897f563547 100644 (file)
@@ -1163,6 +1163,7 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
        int len = 0;
        int msdu_id = -1;
        int res;
+       const u8 *peer_addr;
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data;
 
        len += sizeof(cmd->hdr);
@@ -1178,7 +1179,16 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
             ieee80211_is_deauth(hdr->frame_control) ||
             ieee80211_is_disassoc(hdr->frame_control)) &&
             ieee80211_has_protected(hdr->frame_control)) {
-               skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
+               peer_addr = hdr->addr1;
+               if (is_multicast_ether_addr(peer_addr)) {
+                       skb_put(msdu, sizeof(struct ieee80211_mmie_16));
+               } else {
+                       if (skb_cb->ucast_cipher == WLAN_CIPHER_SUITE_GCMP ||
+                           skb_cb->ucast_cipher == WLAN_CIPHER_SUITE_GCMP_256)
+                               skb_put(msdu, IEEE80211_GCMP_MIC_LEN);
+                       else
+                               skb_put(msdu, IEEE80211_CCMP_MIC_LEN);
+               }
        }
 
        txdesc = ath10k_htc_alloc_skb(ar, len);
index 23d9830d6ed6ed5e561ed4bb3a838b3834882ef7..2d03b8dd3b8c78b415cf446a7d00f87e2ae668df 100644 (file)
@@ -258,6 +258,7 @@ static int ath10k_send_key(struct ath10k_vif *arvif,
        case WLAN_CIPHER_SUITE_GCMP:
        case WLAN_CIPHER_SUITE_GCMP_256:
                arg.key_cipher = ar->wmi_key_cipher[WMI_CIPHER_AES_GCM];
+               key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV_MGMT;
                break;
        case WLAN_CIPHER_SUITE_BIP_GMAC_128:
        case WLAN_CIPHER_SUITE_BIP_GMAC_256:
@@ -3576,6 +3577,7 @@ static void ath10k_tx_h_add_p2p_noa_ie(struct ath10k *ar,
 static void ath10k_mac_tx_h_fill_cb(struct ath10k *ar,
                                    struct ieee80211_vif *vif,
                                    struct ieee80211_txq *txq,
+                                   struct ieee80211_sta *sta,
                                    struct sk_buff *skb, u16 airtime)
 {
        struct ieee80211_hdr *hdr = (void *)skb->data;
@@ -3583,6 +3585,7 @@ static void ath10k_mac_tx_h_fill_cb(struct ath10k *ar,
        const struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
        bool is_data = ieee80211_is_data(hdr->frame_control) ||
                        ieee80211_is_data_qos(hdr->frame_control);
+       struct ath10k_sta *arsta;
 
        cb->flags = 0;
        if (!ath10k_tx_h_use_hwcrypto(vif, skb))
@@ -3607,6 +3610,12 @@ static void ath10k_mac_tx_h_fill_cb(struct ath10k *ar,
        cb->vif = vif;
        cb->txq = txq;
        cb->airtime_est = airtime;
+       if (sta) {
+               arsta = (struct ath10k_sta *)sta->drv_priv;
+               spin_lock_bh(&ar->data_lock);
+               cb->ucast_cipher = arsta->ucast_cipher;
+               spin_unlock_bh(&ar->data_lock);
+       }
 }
 
 bool ath10k_mac_tx_frm_has_freq(struct ath10k *ar)
@@ -4078,7 +4087,7 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,
        }
 
        airtime = ath10k_mac_update_airtime(ar, txq, skb);
-       ath10k_mac_tx_h_fill_cb(ar, vif, txq, skb, airtime);
+       ath10k_mac_tx_h_fill_cb(ar, vif, txq, sta, skb, airtime);
 
        skb_len = skb->len;
        txmode = ath10k_mac_tx_h_get_txmode(ar, vif, sta, skb);
@@ -4348,7 +4357,7 @@ static void ath10k_mac_op_tx(struct ieee80211_hw *hw,
        u16 airtime;
 
        airtime = ath10k_mac_update_airtime(ar, txq, skb);
-       ath10k_mac_tx_h_fill_cb(ar, vif, txq, skb, airtime);
+       ath10k_mac_tx_h_fill_cb(ar, vif, txq, sta, skb, airtime);
 
        txmode = ath10k_mac_tx_h_get_txmode(ar, vif, sta, skb);
        txpath = ath10k_mac_tx_h_get_txpath(ar, skb, txmode);
@@ -6197,6 +6206,7 @@ static int ath10k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 {
        struct ath10k *ar = hw->priv;
        struct ath10k_vif *arvif = (void *)vif->drv_priv;
+       struct ath10k_sta *arsta;
        struct ath10k_peer *peer;
        const u8 *peer_addr;
        bool is_wep = key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
@@ -6221,12 +6231,17 @@ static int ath10k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
 
        mutex_lock(&ar->conf_mutex);
 
-       if (sta)
+       if (sta) {
+               arsta = (struct ath10k_sta *)sta->drv_priv;
                peer_addr = sta->addr;
-       else if (arvif->vdev_type == WMI_VDEV_TYPE_STA)
+               spin_lock_bh(&ar->data_lock);
+               arsta->ucast_cipher = key->cipher;
+               spin_unlock_bh(&ar->data_lock);
+       } else if (arvif->vdev_type == WMI_VDEV_TYPE_STA) {
                peer_addr = vif->bss_conf.bssid;
-       else
+       } else {
                peer_addr = vif->addr;
+       }
 
        key->hw_key_idx = key->keyidx;
 
index e76e3654126a4a8565f62bec7dbdc48fafe92e27..2ea77bb880b19247414ffa3bd7a846a41c761c88 100644 (file)
@@ -1926,6 +1926,7 @@ ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
        u32 vdev_id;
        u32 buf_len = msdu->len;
        u16 fc;
+       const u8 *peer_addr;
 
        hdr = (struct ieee80211_hdr *)msdu->data;
        fc = le16_to_cpu(hdr->frame_control);
@@ -1946,8 +1947,20 @@ ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
             ieee80211_is_deauth(hdr->frame_control) ||
             ieee80211_is_disassoc(hdr->frame_control)) &&
             ieee80211_has_protected(hdr->frame_control)) {
-               len += IEEE80211_CCMP_MIC_LEN;
-               buf_len += IEEE80211_CCMP_MIC_LEN;
+               peer_addr = hdr->addr1;
+               if (is_multicast_ether_addr(peer_addr)) {
+                       len += sizeof(struct ieee80211_mmie_16);
+                       buf_len += sizeof(struct ieee80211_mmie_16);
+               } else {
+                       if (cb->ucast_cipher == WLAN_CIPHER_SUITE_GCMP ||
+                           cb->ucast_cipher == WLAN_CIPHER_SUITE_GCMP_256) {
+                               len += IEEE80211_GCMP_MIC_LEN;
+                               buf_len += IEEE80211_GCMP_MIC_LEN;
+                       } else {
+                               len += IEEE80211_CCMP_MIC_LEN;
+                               buf_len += IEEE80211_CCMP_MIC_LEN;
+                       }
+               }
        }
 
        len = round_up(len, 4);