mwifiex: Don't abort on small, spec-compliant vendor IEs
authorBrian Norris <briannorris@chromium.org>
Sat, 15 Jun 2019 00:13:20 +0000 (17:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Jul 2019 07:04:33 +0000 (09:04 +0200)
commit 63d7ef36103d26f20325a921ecc96a3288560146 upstream.

Per the 802.11 specification, vendor IEs are (at minimum) only required
to contain an OUI. A type field is also included in ieee80211.h (struct
ieee80211_vendor_ie) but doesn't appear in the specification. The
remaining fields (subtype, version) are a convention used in WMM
headers.

Thus, we should not reject vendor-specific IEs that have only the
minimum length (3 bytes) -- we should skip over them (since we only want
to match longer IEs, that match either WMM or WPA formats). We can
reject elements that don't have the minimum-required 3 byte OUI.

While we're at it, move the non-standard subtype and version fields into
the WMM structs, to avoid this confusion in the future about generic
"vendor header" attributes.

Fixes: 685c9b7750bf ("mwifiex: Abort at too short BSS descriptor element")
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/wireless/marvell/mwifiex/fw.h
drivers/net/wireless/marvell/mwifiex/scan.c
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c
drivers/net/wireless/marvell/mwifiex/wmm.c

index 9e75522d248a3e621ee9a8d6a5cca5e9c0bab4e8..342555ebafd79f3da47bf45aba4655a1f19468c6 100644 (file)
@@ -1744,9 +1744,10 @@ struct mwifiex_ie_types_wmm_queue_status {
 struct ieee_types_vendor_header {
        u8 element_id;
        u8 len;
-       u8 oui[4];      /* 0~2: oui, 3: oui_type */
-       u8 oui_subtype;
-       u8 version;
+       struct {
+               u8 oui[3];
+               u8 oui_type;
+       } __packed oui;
 } __packed;
 
 struct ieee_types_wmm_parameter {
@@ -1760,6 +1761,9 @@ struct ieee_types_wmm_parameter {
         *   Version     [1]
         */
        struct ieee_types_vendor_header vend_hdr;
+       u8 oui_subtype;
+       u8 version;
+
        u8 qos_info_bitmap;
        u8 reserved;
        struct ieee_types_wmm_ac_parameters ac_params[IEEE80211_NUM_ACS];
@@ -1777,6 +1781,8 @@ struct ieee_types_wmm_info {
         *   Version     [1]
         */
        struct ieee_types_vendor_header vend_hdr;
+       u8 oui_subtype;
+       u8 version;
 
        u8 qos_info_bitmap;
 } __packed;
index 2f7f4c9e5993bf2314d25a01394601980c744d55..29284f9a0646c1027fa676988426a47e5bd22b51 100644 (file)
@@ -1357,21 +1357,25 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
                        break;
 
                case WLAN_EID_VENDOR_SPECIFIC:
-                       if (element_len + 2 < sizeof(vendor_ie->vend_hdr))
-                               return -EINVAL;
-
                        vendor_ie = (struct ieee_types_vendor_specific *)
                                        current_ptr;
 
-                       if (!memcmp
-                           (vendor_ie->vend_hdr.oui, wpa_oui,
-                            sizeof(wpa_oui))) {
+                       /* 802.11 requires at least 3-byte OUI. */
+                       if (element_len < sizeof(vendor_ie->vend_hdr.oui.oui))
+                               return -EINVAL;
+
+                       /* Not long enough for a match? Skip it. */
+                       if (element_len < sizeof(wpa_oui))
+                               break;
+
+                       if (!memcmp(&vendor_ie->vend_hdr.oui, wpa_oui,
+                                   sizeof(wpa_oui))) {
                                bss_entry->bcn_wpa_ie =
                                        (struct ieee_types_vendor_specific *)
                                        current_ptr;
                                bss_entry->wpa_offset = (u16)
                                        (current_ptr - bss_entry->beacon_buf);
-                       } else if (!memcmp(vendor_ie->vend_hdr.oui, wmm_oui,
+                       } else if (!memcmp(&vendor_ie->vend_hdr.oui, wmm_oui,
                                    sizeof(wmm_oui))) {
                                if (total_ie_len ==
                                    sizeof(struct ieee_types_wmm_parameter) ||
index a6077ab3efc3244d80c99d74e5e4c68fa74ab67a..82828a2079638ebcc789ff2ad81c47a53de0eb2e 100644 (file)
@@ -1388,7 +1388,7 @@ mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
                        /* Test to see if it is a WPA IE, if not, then
                         * it is a gen IE
                         */
-                       if (!memcmp(pvendor_ie->oui, wpa_oui,
+                       if (!memcmp(&pvendor_ie->oui, wpa_oui,
                                    sizeof(wpa_oui))) {
                                /* IE is a WPA/WPA2 IE so call set_wpa function
                                 */
@@ -1398,7 +1398,7 @@ mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
                                goto next_ie;
                        }
 
-                       if (!memcmp(pvendor_ie->oui, wps_oui,
+                       if (!memcmp(&pvendor_ie->oui, wps_oui,
                                    sizeof(wps_oui))) {
                                /* Test to see if it is a WPS IE,
                                 * if so, enable wps session flag
index 0edd26881321e50335b92d54469b8b7d7357c1ba..7fba4d940131c8042a64827c4457dd73dbf10980 100644 (file)
@@ -240,7 +240,7 @@ mwifiex_wmm_setup_queue_priorities(struct mwifiex_private *priv,
        mwifiex_dbg(priv->adapter, INFO,
                    "info: WMM Parameter IE: version=%d,\t"
                    "qos_info Parameter Set Count=%d, Reserved=%#x\n",
-                   wmm_ie->vend_hdr.version, wmm_ie->qos_info_bitmap &
+                   wmm_ie->version, wmm_ie->qos_info_bitmap &
                    IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK,
                    wmm_ie->reserved);