Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: check power constraint IE size when parsing

The power constraint IE is always a single byte
so check the size when parsing instead of later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+6 -10
-1
net/mac80211/ieee80211_i.h
··· 1165 1165 u8 prep_len; 1166 1166 u8 perr_len; 1167 1167 u8 country_elem_len; 1168 - u8 pwr_constr_elem_len; 1169 1168 u8 quiet_elem_len; 1170 1169 u8 num_of_quiet_elem; /* can be more the one */ 1171 1170 u8 timeout_int_len;
+2 -8
net/mac80211/mlme.c
··· 821 821 } 822 822 823 823 static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata, 824 - u16 capab_info, u8 *pwr_constr_elem, 825 - u8 pwr_constr_elem_len) 824 + u16 capab_info, u8 *pwr_constr_elem) 826 825 { 827 826 struct ieee80211_conf *conf = &sdata->local->hw.conf; 828 827 829 828 if (!(capab_info & WLAN_CAPABILITY_SPECTRUM_MGMT)) 830 - return; 831 - 832 - /* Power constraint IE length should be 1 octet */ 833 - if (pwr_constr_elem_len != 1) 834 829 return; 835 830 836 831 if ((*pwr_constr_elem <= conf->channel->max_reg_power) && ··· 2547 2552 if (elems.pwr_constr_elem) 2548 2553 ieee80211_handle_pwr_constr(sdata, 2549 2554 le16_to_cpu(mgmt->u.probe_resp.capab_info), 2550 - elems.pwr_constr_elem, 2551 - elems.pwr_constr_elem_len); 2555 + elems.pwr_constr_elem); 2552 2556 } 2553 2557 2554 2558 ieee80211_bss_info_change_notify(sdata, changed);
+4 -1
net/mac80211/util.c
··· 792 792 elems->country_elem_len = elen; 793 793 break; 794 794 case WLAN_EID_PWR_CONSTRAINT: 795 + if (elen != 1) { 796 + elem_parse_failed = true; 797 + break; 798 + } 795 799 elems->pwr_constr_elem = pos; 796 - elems->pwr_constr_elem_len = elen; 797 800 break; 798 801 case WLAN_EID_TIMEOUT_INTERVAL: 799 802 elems->timeout_int = pos;