Skip to content

Commit d4ac640

Browse files
Dan Carpentergregkh
authored andcommitted
staging: rtl8188eu: fix potential memory corruption in rtw_check_beacon_data()
The "ie_len" is a value in the 1-255 range that comes from the user. We have to cap it to ensure that it's not too large or it could lead to memory corruption. Fixes: 9a7fe54 ("staging: r8188eu: Add source files for new driver - part 1") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: stable <stable@vger.kernel.org> Link: https://lore.kernel.org/r/YEHyQCrFZKTXyT7J@mwanda Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8710751 commit d4ac640

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/staging/rtl8188eu/core/rtw_ap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
791791
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len,
792792
pbss_network->ie_length - _BEACON_IE_OFFSET_);
793793
if (p && ie_len > 0) {
794+
ie_len = min_t(int, ie_len, sizeof(pbss_network->ssid.ssid));
794795
memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid));
795796
memcpy(pbss_network->ssid.ssid, p + 2, ie_len);
796797
pbss_network->ssid.ssid_length = ie_len;
@@ -811,6 +812,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
811812
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len,
812813
pbss_network->ie_length - _BEACON_IE_OFFSET_);
813814
if (p) {
815+
ie_len = min_t(int, ie_len, NDIS_802_11_LENGTH_RATES_EX);
814816
memcpy(supportRate, p + 2, ie_len);
815817
supportRateNum = ie_len;
816818
}
@@ -819,6 +821,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
819821
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES,
820822
&ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_);
821823
if (p) {
824+
ie_len = min_t(int, ie_len,
825+
NDIS_802_11_LENGTH_RATES_EX - supportRateNum);
822826
memcpy(supportRate + supportRateNum, p + 2, ie_len);
823827
supportRateNum += ie_len;
824828
}
@@ -934,6 +938,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
934938

935939
pht_cap->mcs.rx_mask[0] = 0xff;
936940
pht_cap->mcs.rx_mask[1] = 0x0;
941+
ie_len = min_t(int, ie_len, sizeof(pmlmepriv->htpriv.ht_cap));
937942
memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len);
938943
}
939944

0 commit comments

Comments
 (0)