Skip to content

Commit c1707c5

Browse files
jmalinengregkh
authored andcommitted
mac80211: Do not use stack memory with scatterlist for GMAC
commit a71fd9d upstream. 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: [email protected] Signed-off-by: Jouni Malinen <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9f0f5ff commit c1707c5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/mac80211/wpa.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
11691169
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
11701170
struct ieee80211_key *key = rx->key;
11711171
struct ieee80211_mmie_16 *mmie;
1172-
u8 aad[GMAC_AAD_LEN], mic[GMAC_MIC_LEN], ipn[6], nonce[GMAC_NONCE_LEN];
1172+
u8 aad[GMAC_AAD_LEN], *mic, ipn[6], nonce[GMAC_NONCE_LEN];
11731173
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
11741174

11751175
if (!ieee80211_is_mgmt(hdr->frame_control))
@@ -1200,13 +1200,18 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx)
12001200
memcpy(nonce, hdr->addr2, ETH_ALEN);
12011201
memcpy(nonce + ETH_ALEN, ipn, 6);
12021202

1203+
mic = kmalloc(GMAC_MIC_LEN, GFP_ATOMIC);
1204+
if (!mic)
1205+
return RX_DROP_UNUSABLE;
12031206
if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce,
12041207
skb->data + 24, skb->len - 24,
12051208
mic) < 0 ||
12061209
crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) {
12071210
key->u.aes_gmac.icverrors++;
1211+
kfree(mic);
12081212
return RX_DROP_UNUSABLE;
12091213
}
1214+
kfree(mic);
12101215
}
12111216

12121217
memcpy(key->u.aes_gmac.rx_pn, ipn, 6);

0 commit comments

Comments
 (0)