1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 28 Jan 2019 13:16:45 +0100
3 Subject: [PATCH] mac80211: ensure that management tx skbs have encryption
6 Some drivers use IEEE80211_KEY_FLAG_SW_MGMT_TX to indicate that management
7 frames need to be software encrypted. Since normal data packets are still
8 encrypted by the hardware, crypto_tx_tailroom_needed_cnt gets decremented
9 after key upload. This can lead to passing skbs to ccmp_encrypt_skb, which
10 don't have the needed tailroom for software encryption.
12 Change the code to add tailroom for encrypted management packets, even if
13 crypto_tx_tailroom_needed_cnt is 0.
15 Cc: stable@vger.kernel.org
16 Signed-off-by: Felix Fietkau <nbd@nbd.name>
19 --- a/net/mac80211/tx.c
20 +++ b/net/mac80211/tx.c
21 @@ -1912,9 +1912,16 @@ static int ieee80211_skb_resize(struct i
22 int head_need, bool may_encrypt)
24 struct ieee80211_local *local = sdata->local;
25 + struct ieee80211_hdr *hdr;
29 - if (may_encrypt && sdata->crypto_tx_tailroom_needed_cnt) {
30 + hdr = (struct ieee80211_hdr *) skb->data;
31 + enc_tailroom = may_encrypt &&
32 + (sdata->crypto_tx_tailroom_needed_cnt ||
33 + ieee80211_is_mgmt(hdr->frame_control));
36 tail_need = IEEE80211_ENCRYPT_TAILROOM;
37 tail_need -= skb_tailroom(skb);
38 tail_need = max_t(int, tail_need, 0);
39 @@ -1922,8 +1929,7 @@ static int ieee80211_skb_resize(struct i
41 if (skb_cloned(skb) &&
42 (!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) ||
43 - !skb_clone_writable(skb, ETH_HLEN) ||
44 - (may_encrypt && sdata->crypto_tx_tailroom_needed_cnt)))
45 + !skb_clone_writable(skb, ETH_HLEN) || enc_tailroom))
46 I802_DEBUG_INC(local->tx_expand_skb_head_cloned);
47 else if (head_need || tail_need)
48 I802_DEBUG_INC(local->tx_expand_skb_head);