summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2019-05-27 18:46:43 -0400
committerJohannes Berg <johannes.berg@intel.com>2019-05-28 03:22:12 -0400
commita71fd9dac23613d96ba3c05619a8ef4fd6cdf9b9 (patch)
tree6ec236650945100d3e9333edbb336b5c4cd56eee
parent33d915d9e8ce811d8958915ccd18d71a66c7c495 (diff)
mac80211: Do not use stack memory with scatterlist for GMAC
ieee80211_aes_gmac() uses the mic argument directly in sg_set_buf() and that does not allow use of stack memory (e.g., BUG_ON() is hit in sg_set_buf() with CONFIG_DEBUG_SG). BIP GMAC TX side is fine for this since it can use the skb data buffer, but the RX side was using a stack variable for deriving the local MIC value to compare against the received one. Fix this by allocating heap memory for the mic buffer. This was found with hwsim test case ap_cipher_bip_gmac_128 hitting that BUG_ON() and kernel panic. Cc: stable@vger.kernel.org Signed-off-by: Jouni Malinen <j@w1.fi> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--net/mac80211/wpa.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 58d0b258b684..5dd48f0a4b1b 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -1175,7 +1175,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
1175 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 1175 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
1176 struct ieee80211_key *key = rx->key; 1176 struct ieee80211_key *key = rx->key;
1177 struct ieee80211_mmie_16 *mmie; 1177 struct ieee80211_mmie_16 *mmie;
1178 u8 aad[GMAC_AAD_LEN], mic[GMAC_MIC_LEN], ipn[6], nonce[GMAC_NONCE_LEN]; 1178 u8 aad[GMAC_AAD_LEN], *mic, ipn[6], nonce[GMAC_NONCE_LEN];
1179 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 1179 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
1180 1180
1181 if (!ieee80211_is_mgmt(hdr->frame_control)) 1181 if (!ieee80211_is_mgmt(hdr->frame_control))
@@ -1206,13 +1206,18 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
1206 memcpy(nonce, hdr->addr2, ETH_ALEN); 1206 memcpy(nonce, hdr->addr2, ETH_ALEN);
1207 memcpy(nonce + ETH_ALEN, ipn, 6); 1207 memcpy(nonce + ETH_ALEN, ipn, 6);
1208 1208
1209 mic = kmalloc(GMAC_MIC_LEN, GFP_ATOMIC);
1210 if (!mic)
1211 return RX_DROP_UNUSABLE;
1209 if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce, 1212 if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce,
1210 skb->data + 24, skb->len - 24, 1213 skb->data + 24, skb->len - 24,
1211 mic) < 0 || 1214 mic) < 0 ||
1212 crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { 1215 crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
1213 key->u.aes_gmac.icverrors++; 1216 key->u.aes_gmac.icverrors++;
1217 kfree(mic);
1214 return RX_DROP_UNUSABLE; 1218 return RX_DROP_UNUSABLE;
1215 } 1219 }
1220 kfree(mic);
1216 } 1221 }
1217 1222
1218 memcpy(key->u.aes_gmac.rx_pn, ipn, 6); 1223 memcpy(key->u.aes_gmac.rx_pn, ipn, 6);