Skip to content

Commit 4a4f1a5

Browse files
committed
mac80211: check management frame header length
Due to pskb_may_pull() checking the skb length, all non-management frames are checked on input whether their 802.11 header is fully present. Also add that check for management frames and remove a check that is now duplicate. This prevents accessing skb data beyond the frame end. Cc: [email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 7dd111e commit 4a4f1a5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/mac80211/rx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,6 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
14701470
frag = sc & IEEE80211_SCTL_FRAG;
14711471

14721472
if (likely((!ieee80211_has_morefrags(fc) && frag == 0) ||
1473-
(rx->skb)->len < 24 ||
14741473
is_multicast_ether_addr(hdr->addr1))) {
14751474
/* not fragmented */
14761475
goto out;
@@ -2915,10 +2914,15 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
29152914
if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc))
29162915
local->dot11ReceivedFragmentCount++;
29172916

2918-
if (ieee80211_is_mgmt(fc))
2919-
err = skb_linearize(skb);
2920-
else
2917+
if (ieee80211_is_mgmt(fc)) {
2918+
/* drop frame if too short for header */
2919+
if (skb->len < ieee80211_hdrlen(fc))
2920+
err = -ENOBUFS;
2921+
else
2922+
err = skb_linearize(skb);
2923+
} else {
29212924
err = !pskb_may_pull(skb, ieee80211_hdrlen(fc));
2925+
}
29222926

29232927
if (err) {
29242928
dev_kfree_skb(skb);

0 commit comments

Comments
 (0)