352-mac80211-fix-use-after-free-in-defragmentation.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. From: Johannes Berg <[email protected]>
  2. Date: Mon, 3 Nov 2014 14:29:09 +0100
  3. Subject: [PATCH] mac80211: fix use-after-free in defragmentation
  4. Upon receiving the last fragment, all but the first fragment
  5. are freed, but the multicast check for statistics at the end
  6. of the function refers to the current skb (the last fragment)
  7. causing a use-after-free bug.
  8. Since multicast frames cannot be fragmented and we check for
  9. this early in the function, just modify that check to also
  10. do the accounting to fix the issue.
  11. Cc: [email protected]
  12. Reported-by: Yosef Khyal <[email protected]>
  13. Signed-off-by: Johannes Berg <[email protected]>
  14. ---
  15. --- a/net/mac80211/rx.c
  16. +++ b/net/mac80211/rx.c
  17. @@ -1678,11 +1678,14 @@ ieee80211_rx_h_defragment(struct ieee802
  18. sc = le16_to_cpu(hdr->seq_ctrl);
  19. frag = sc & IEEE80211_SCTL_FRAG;
  20. - if (likely((!ieee80211_has_morefrags(fc) && frag == 0) ||
  21. - is_multicast_ether_addr(hdr->addr1))) {
  22. - /* not fragmented */
  23. + if (likely(!ieee80211_has_morefrags(fc) && frag == 0))
  24. + goto out;
  25. +
  26. + if (is_multicast_ether_addr(hdr->addr1)) {
  27. + rx->local->dot11MulticastReceivedFrameCount++;
  28. goto out;
  29. }
  30. +
  31. I802_DEBUG_INC(rx->local->rx_handlers_fragments);
  32. if (skb_linearize(rx->skb))
  33. @@ -1775,10 +1778,7 @@ ieee80211_rx_h_defragment(struct ieee802
  34. out:
  35. if (rx->sta)
  36. rx->sta->rx_packets++;
  37. - if (is_multicast_ether_addr(hdr->addr1))
  38. - rx->local->dot11MulticastReceivedFrameCount++;
  39. - else
  40. - ieee80211_led_rx(rx->local);
  41. + ieee80211_led_rx(rx->local);
  42. return RX_CONTINUE;
  43. }