summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshish Kumar Dhanotiya <adhanoti@codeaurora.org>2019-12-12 14:17:03 +0530
committerIsaac Chiou <isaacchiou@google.com>2020-05-18 14:42:34 +0800
commit725e65c70af7878f9cfdf779ce53bf93fd0e8a5b (patch)
treec664af5a4b19751578cc9816ffb43dc6d5e866b6
parent6e094d3e5c3544ff04f75454979025a2f4795e40 (diff)
downloadqcacld-725e65c70af7878f9cfdf779ce53bf93fd0e8a5b.tar.gz
qcacld-3.0: Validate assoc response IE len before copy
When host sends ft assoc response to supplicant, it allocates a buffer of fixed size and copies a variable length of assoc response IEs to this fixed sized buffer. There is a possibility of OOB write to the allocated buffer if the assoc response IEs length is greater than the allocated buffer size. To avoid above issue validate the assoc response IEs length with the allocated buffer size before data copy to the buffer. Bug: 155654321 Change-ID: Ife9c2071a8cc4a2918b9f349f4024478f94b2d78 CRs-Fixed: 2575144
-rw-r--r--core/hdd/src/wlan_hdd_assoc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/hdd/src/wlan_hdd_assoc.c b/core/hdd/src/wlan_hdd_assoc.c
index b543894b5a..ef43e194dd 100644
--- a/core/hdd/src/wlan_hdd_assoc.c
+++ b/core/hdd/src/wlan_hdd_assoc.c
@@ -1076,8 +1076,9 @@ hdd_send_ft_assoc_response(struct net_device *dev,
unsigned int len = 0;
u8 *pFTAssocRsp = NULL;
- if (pCsrRoamInfo->nAssocRspLength == 0) {
- hdd_debug("assoc rsp length is 0");
+ if (pCsrRoamInfo->nAssocRspLength < FT_ASSOC_RSP_IES_OFFSET) {
+ hdd_debug("Invalid assoc rsp length %d",
+ pCsrRoamInfo->nAssocRspLength);
return;
}
@@ -1094,15 +1095,20 @@ hdd_send_ft_assoc_response(struct net_device *dev,
(unsigned int)pFTAssocRsp[0],
(unsigned int)pFTAssocRsp[1]);
+ /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
+ len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
+ if (len > IW_GENERIC_IE_MAX) {
+ hdd_err("Invalid Assoc resp length %d", len);
+ return;
+ }
+ wrqu.data.length = len;
+
/* We need to send the IEs to the supplicant. */
buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
if (buff == NULL) {
hdd_err("unable to allocate memory");
return;
}
- /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
- len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
- wrqu.data.length = len;
memcpy(buff, pFTAssocRsp, len);
wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);