staging: rtl8188eu: fix potential memory corruption in rtw_check_beacon_data()
commit d4ac640322b06095128a5c45ba4a1e80929fe7f3 upstream.
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: 9a7fe54ddc
("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>
This commit is contained in:
parent
1a866057e9
commit
ab42f28d5f
|
@ -784,6 +784,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
|
||||||
/* SSID */
|
/* SSID */
|
||||||
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->ie_length - _BEACON_IE_OFFSET_));
|
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->ie_length - _BEACON_IE_OFFSET_));
|
||||||
if (p && ie_len > 0) {
|
if (p && ie_len > 0) {
|
||||||
|
ie_len = min_t(int, ie_len, sizeof(pbss_network->ssid.ssid));
|
||||||
memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid));
|
memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid));
|
||||||
memcpy(pbss_network->ssid.ssid, (p + 2), ie_len);
|
memcpy(pbss_network->ssid.ssid, (p + 2), ie_len);
|
||||||
pbss_network->ssid.ssid_length = ie_len;
|
pbss_network->ssid.ssid_length = ie_len;
|
||||||
|
@ -802,6 +803,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
|
||||||
/* get supported rates */
|
/* get supported rates */
|
||||||
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->ie_length - _BEACON_IE_OFFSET_));
|
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->ie_length - _BEACON_IE_OFFSET_));
|
||||||
if (p) {
|
if (p) {
|
||||||
|
ie_len = min_t(int, ie_len, NDIS_802_11_LENGTH_RATES_EX);
|
||||||
memcpy(supportRate, p + 2, ie_len);
|
memcpy(supportRate, p + 2, ie_len);
|
||||||
supportRateNum = ie_len;
|
supportRateNum = ie_len;
|
||||||
}
|
}
|
||||||
|
@ -809,6 +811,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
|
||||||
/* get ext_supported rates */
|
/* get ext_supported rates */
|
||||||
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_);
|
p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_);
|
||||||
if (p) {
|
if (p) {
|
||||||
|
ie_len = min_t(int, ie_len,
|
||||||
|
NDIS_802_11_LENGTH_RATES_EX - supportRateNum);
|
||||||
memcpy(supportRate + supportRateNum, p + 2, ie_len);
|
memcpy(supportRate + supportRateNum, p + 2, ie_len);
|
||||||
supportRateNum += ie_len;
|
supportRateNum += ie_len;
|
||||||
}
|
}
|
||||||
|
@ -922,6 +926,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
|
||||||
|
|
||||||
pht_cap->mcs.rx_mask[0] = 0xff;
|
pht_cap->mcs.rx_mask[0] = 0xff;
|
||||||
pht_cap->mcs.rx_mask[1] = 0x0;
|
pht_cap->mcs.rx_mask[1] = 0x0;
|
||||||
|
ie_len = min_t(int, ie_len, sizeof(pmlmepriv->htpriv.ht_cap));
|
||||||
memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len);
|
memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue