]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mac80211: check management frame header length
authorJohannes Berg <johannes.berg@intel.com>
Thu, 25 Oct 2012 22:33:36 +0000 (00:33 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 16 Nov 2012 16:46:58 +0000 (16:46 +0000)
commit 4a4f1a5808c8bb0b72a4f6e5904c53fb8c9cd966 upstream.

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.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/mac80211/rx.c

index 8c6f3378984450e2327884e2e3408b95d1229242..f9f8f36f42fa3dd55797a05f0a43721b9555cb82 100644 (file)
@@ -1457,7 +1457,6 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
        frag = sc & IEEE80211_SCTL_FRAG;
 
        if (likely((!ieee80211_has_morefrags(fc) && frag == 0) ||
-                  (rx->skb)->len < 24 ||
                   is_multicast_ether_addr(hdr->addr1))) {
                /* not fragmented */
                goto out;
@@ -2875,10 +2874,15 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
                     test_bit(SCAN_OFF_CHANNEL, &local->scanning)))
                status->rx_flags |= IEEE80211_RX_IN_SCAN;
 
-       if (ieee80211_is_mgmt(fc))
-               err = skb_linearize(skb);
-       else
+       if (ieee80211_is_mgmt(fc)) {
+               /* drop frame if too short for header */
+               if (skb->len < ieee80211_hdrlen(fc))
+                       err = -ENOBUFS;
+               else
+                       err = skb_linearize(skb);
+       } else {
                err = !pskb_may_pull(skb, ieee80211_hdrlen(fc));
+       }
 
        if (err) {
                dev_kfree_skb(skb);