mac80211: properly handle A-MSDUs that start with an RFC 1042 header
authorMathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
Mon, 31 May 2021 20:31:28 +0000 (22:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Jun 2021 06:36:13 +0000 (08:36 +0200)
commit a1d5ff5651ea592c67054233b14b30bf4452999c upstream.

Properly parse A-MSDUs whose first 6 bytes happen to equal a rfc1042
header. This can occur in practice when the destination MAC address
equals AA:AA:03:00:00:00. More importantly, this simplifies the next
patch to mitigate A-MSDU injection attacks.

Cc: stable@vger.kernel.org
Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
Link: https://lore.kernel.org/r/20210511200110.0b2b886492f0.I23dd5d685fe16d3b0ec8106e8f01b59f499dffed@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/cfg80211.h
net/mac80211/rx.c
net/wireless/util.c

index 030eea38f25818b0406ed1ddec32835d0a8decd4..be161f82abc661993f65fb8fa8081fdbc136832a 100644 (file)
@@ -4338,7 +4338,8 @@ unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
  * Return: 0 on success. Non-zero on error.
  */
 int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
-                                 const u8 *addr, enum nl80211_iftype iftype);
+                                 const u8 *addr, enum nl80211_iftype iftype,
+                                 bool is_amsdu);
 
 /**
  * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
@@ -4350,7 +4351,7 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
 static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
                                         enum nl80211_iftype iftype)
 {
-       return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype);
+       return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, false);
 }
 
 /**
index 8c126854aa067b3788b1e048ea08f4ed39c902b9..be7e37edad122ca6fd2d67c532c071587d3131b8 100644 (file)
@@ -2451,7 +2451,8 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
 
        if (ieee80211_data_to_8023_exthdr(skb, &ethhdr,
                                          rx->sdata->vif.addr,
-                                         rx->sdata->vif.type))
+                                         rx->sdata->vif.type,
+                                         true))
                return RX_DROP_UNUSABLE;
 
        ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr,
index 935929b454115535d8b06691ef19599e210270c5..2aef1c487be6af152ca7a9aec7d544e83b503b43 100644 (file)
@@ -422,7 +422,8 @@ unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr)
 EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen);
 
 int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
-                                 const u8 *addr, enum nl80211_iftype iftype)
+                                 const u8 *addr, enum nl80211_iftype iftype,
+                                 bool is_amsdu)
 {
        struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        struct {
@@ -510,7 +511,7 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
        skb_copy_bits(skb, hdrlen, &payload, sizeof(payload));
        tmp.h_proto = payload.proto;
 
-       if (likely((ether_addr_equal(payload.hdr, rfc1042_header) &&
+       if (likely((!is_amsdu && ether_addr_equal(payload.hdr, rfc1042_header) &&
                    tmp.h_proto != htons(ETH_P_AARP) &&
                    tmp.h_proto != htons(ETH_P_IPX)) ||
                   ether_addr_equal(payload.hdr, bridge_tunnel_header)))