Skip to content

Commit b8fff40

Browse files
committed
mac80211: fix use-after-free in defragmentation
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. Cc: stable@vger.kernel.org Reported-by: Yosef Khyal <yosefx.khyal@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 4623884 commit b8fff40

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎net/mac80211/rx.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,11 +1678,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
16781678
sc = le16_to_cpu(hdr->seq_ctrl);
16791679
frag = sc & IEEE80211_SCTL_FRAG;
16801680

1681-
if (likely((!ieee80211_has_morefrags(fc) && frag == 0) ||
1682-
is_multicast_ether_addr(hdr->addr1))) {
1683-
/* not fragmented */
1681+
if (likely(!ieee80211_has_morefrags(fc) && frag == 0))
1682+
goto out;
1683+
1684+
if (is_multicast_ether_addr(hdr->addr1)) {
1685+
rx->local->dot11MulticastReceivedFrameCount++;
16841686
goto out;
16851687
}
1688+
16861689
I802_DEBUG_INC(rx->local->rx_handlers_fragments);
16871690

16881691
if (skb_linearize(rx->skb))
@@ -1775,10 +1778,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
17751778
out:
17761779
if (rx->sta)
17771780
rx->sta->rx_packets++;
1778-
if (is_multicast_ether_addr(hdr->addr1))
1779-
rx->local->dot11MulticastReceivedFrameCount++;
1780-
else
1781-
ieee80211_led_rx(rx->local);
1781+
ieee80211_led_rx(rx->local);
17821782
return RX_CONTINUE;
17831783
}
17841784

0 commit comments

Comments
 (0)