384-mac80211-ensure-that-management-tx-skbs-have-encrypt.patch 1.8 KB

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