Skip to content

Commit 2243296

Browse files
nbd168gregkh
authored andcommitted
mac80211: ensure that mgmt tx skbs have tailroom for encryption
commit 9d0f50b upstream. Some drivers use IEEE80211_KEY_FLAG_SW_MGMT_TX to indicate that management frames need to be software encrypted. Since normal data packets are still encrypted by the hardware, crypto_tx_tailroom_needed_cnt gets decremented after key upload to hw. This can lead to passing skbs to ccmp_encrypt_skb, which don't have the necessary tailroom for software encryption. Change the code to add tailroom for encrypted management packets, even if crypto_tx_tailroom_needed_cnt is 0. Cc: [email protected] Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 39551af commit 2243296

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

net/mac80211/tx.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,18 +1856,24 @@ static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata,
18561856
int head_need, bool may_encrypt)
18571857
{
18581858
struct ieee80211_local *local = sdata->local;
1859+
struct ieee80211_hdr *hdr;
1860+
bool enc_tailroom;
18591861
int tail_need = 0;
18601862

1861-
if (may_encrypt && sdata->crypto_tx_tailroom_needed_cnt) {
1863+
hdr = (struct ieee80211_hdr *) skb->data;
1864+
enc_tailroom = may_encrypt &&
1865+
(sdata->crypto_tx_tailroom_needed_cnt ||
1866+
ieee80211_is_mgmt(hdr->frame_control));
1867+
1868+
if (enc_tailroom) {
18621869
tail_need = IEEE80211_ENCRYPT_TAILROOM;
18631870
tail_need -= skb_tailroom(skb);
18641871
tail_need = max_t(int, tail_need, 0);
18651872
}
18661873

18671874
if (skb_cloned(skb) &&
18681875
(!ieee80211_hw_check(&local->hw, SUPPORTS_CLONED_SKBS) ||
1869-
!skb_clone_writable(skb, ETH_HLEN) ||
1870-
(may_encrypt && sdata->crypto_tx_tailroom_needed_cnt)))
1876+
!skb_clone_writable(skb, ETH_HLEN) || enc_tailroom))
18711877
I802_DEBUG_INC(local->tx_expand_skb_head_cloned);
18721878
else if (head_need || tail_need)
18731879
I802_DEBUG_INC(local->tx_expand_skb_head);

0 commit comments

Comments
 (0)