mwifiex: Abort at too short BSS descriptor element [Linux 4.4.186]

This Linux kernel change "mwifiex: Abort at too short BSS descriptor element" is included in the Linux 4.4.186 release. This change is authored by Takashi Iwai <tiwai [at] suse.de> on Wed May 29 14:52:20 2019 +0200. The commit for this change in Linux stable tree is f80d2b5 (patch) which is from upstream commit 685c9b7. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 685c9b7.

mwifiex: Abort at too short BSS descriptor element

commit 685c9b7750bfacd6fc1db50d86579980593b7869 upstream.

Currently mwifiex_update_bss_desc_with_ie() implicitly assumes that
the source descriptor entries contain the enough size for each type
and performs copying without checking the source size.  This may lead
to read over boundary.

Fix this by putting the source size check in appropriate places.

Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

There are 15 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/wireless/mwifiex/scan.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 6f78989..b755f72 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -1241,6 +1241,8 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
            break;

        case WLAN_EID_FH_PARAMS:
+           if (element_len + 2 < sizeof(*fh_param_set))
+               return -EINVAL;
            fh_param_set =
                (struct ieee_types_fh_param_set *) current_ptr;
            memcpy(&bss_entry->phy_param_set.fh_param_set,
@@ -1249,6 +1251,8 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
            break;

        case WLAN_EID_DS_PARAMS:
+           if (element_len + 2 < sizeof(*ds_param_set))
+               return -EINVAL;
            ds_param_set =
                (struct ieee_types_ds_param_set *) current_ptr;

@@ -1260,6 +1264,8 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
            break;

        case WLAN_EID_CF_PARAMS:
+           if (element_len + 2 < sizeof(*cf_param_set))
+               return -EINVAL;
            cf_param_set =
                (struct ieee_types_cf_param_set *) current_ptr;
            memcpy(&bss_entry->ss_param_set.cf_param_set,
@@ -1268,6 +1274,8 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
            break;

        case WLAN_EID_IBSS_PARAMS:
+           if (element_len + 2 < sizeof(*ibss_param_set))
+               return -EINVAL;
            ibss_param_set =
                (struct ieee_types_ibss_param_set *)
                current_ptr;
@@ -1277,10 +1285,14 @@ int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
            break;

        case WLAN_EID_ERP_INFO:
+           if (!element_len)
+               return -EINVAL;
            bss_entry->erp_flags = *(current_ptr + 2);
            break;

        case WLAN_EID_PWR_CONSTRAINT:
+           if (!element_len)
+               return -EINVAL;
            bss_entry->local_constraint = *(current_ptr + 2);
            bss_entry->sensed_11h = true;
            break;
@@ -1320,6 +1332,9 @@ 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;

Leave a Reply

Your email address will not be published. Required fields are marked *