Skip to content

Commit

Permalink
mac80211: fix use-after-free in defragmentation
Browse files Browse the repository at this point in the history
commit b8fff40 upstream.

Upon receiving the last fragment, all but the first fragment
are freed, but the multicast check for statistics at the end
of the function refers to the current skb (the last fragment)
causing a use-after-free bug.

Since multicast frames cannot be fragmented and we check for
this early in the function, just modify that check to also
do the accounting to fix the issue.

Reported-by: Yosef Khyal <yosefx.khyal@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
jmberg-intel authored and gregkh committed Nov 21, 2014
1 parent b34fafa commit 2e613ff
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/mac80211/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,11 +1585,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
sc = le16_to_cpu(hdr->seq_ctrl);
frag = sc & IEEE80211_SCTL_FRAG;

if (likely((!ieee80211_has_morefrags(fc) && frag == 0) ||
is_multicast_ether_addr(hdr->addr1))) {
/* not fragmented */
if (likely(!ieee80211_has_morefrags(fc) && frag == 0))
goto out;

if (is_multicast_ether_addr(hdr->addr1)) {
rx->local->dot11MulticastReceivedFrameCount++;
goto out;
}

I802_DEBUG_INC(rx->local->rx_handlers_fragments);

if (skb_linearize(rx->skb))
Expand Down Expand Up @@ -1682,10 +1685,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
out:
if (rx->sta)
rx->sta->rx_packets++;
if (is_multicast_ether_addr(hdr->addr1))
rx->local->dot11MulticastReceivedFrameCount++;
else
ieee80211_led_rx(rx->local);
ieee80211_led_rx(rx->local);
return RX_CONTINUE;
}

Expand Down

0 comments on commit 2e613ff

Please sign in to comment.