From ecc036137eb0bfd9005a799047d416ea4998c558 Mon Sep 17 00:00:00 2001 From: Jingxiang Ge Date: Mon, 24 Feb 2020 13:17:51 +0800 Subject: [PATCH] qcacld-2.0: Validate assoc response IE len before copy Propagate from qcacld3.0 to qcacld2.0 When host sends 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. Change-ID: Ib12385e9ff04e5172ae8b505faf959e426fda439 CRs-Fixed: 2616229 --- .../wireless/qcacld-2.0/CORE/HDD/src/wlan_hdd_assoc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/qcacld-2.0/CORE/HDD/src/wlan_hdd_assoc.c b/drivers/net/wireless/qcacld-2.0/CORE/HDD/src/wlan_hdd_assoc.c index 79f3b1110ffd..f5e75c7af036 100644 --- a/drivers/net/wireless/qcacld-2.0/CORE/HDD/src/wlan_hdd_assoc.c +++ b/drivers/net/wireless/qcacld-2.0/CORE/HDD/src/wlan_hdd_assoc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2016, 2020 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -1364,8 +1364,9 @@ static void hdd_SendReAssocEvent(struct net_device *dev, goto done; } - if (pCsrRoamInfo->nAssocRspLength == 0) { - hddLog(LOGE, FL("Invalid assoc response length")); + if (pCsrRoamInfo->nAssocRspLength < FT_ASSOC_RSP_IES_OFFSET) { + hddLog(LOGE, FL("Invalid assoc response length %d"), + pCsrRoamInfo->nAssocRspLength); goto done; } @@ -1390,6 +1391,10 @@ static void hdd_SendReAssocEvent(struct net_device *dev, /* 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) { + hddLog(LOGE, FL("Invalid Assoc resp length %d"), len); + goto done; + } rspRsnLength = len; memcpy(rspRsnIe, pFTAssocRsp, len); memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);