Skip to content
Snippets Groups Projects
Commit 25966c54 authored by Srinivas Girigowda's avatar Srinivas Girigowda Committed by Thierry Strudel
Browse files

qcacld-2.0: Fix potential buffer overwrite in wma_roam_synch_event_handler


In the function wma_roam_synch_event_handler, vdev_id is received from
the fw and is used to access member of the array wma->interfaces without
validating the max of the vdev_id received from the fw

Add check to make sure vdev_id is less than max_bssid before using it

Change-Id: I3b940e183ab66680891cb7351af4537b50afce1d
CRs-Fixed: 2147083
Bug: 68992434
Signed-off-by: default avatarSrinivas Girigowda <sgirigow@codeaurora.org>
parent 585aad3e
Branches
Tags android-8.1.0_r0.22
No related merge requests found
......@@ -6606,6 +6606,7 @@ static int wma_roam_synch_event_handler(void *handle, u_int8_t *event, u_int32_t
wmi_key_material *key = NULL;
int size=0;
tSirRoamOffloadSynchInd *pRoamOffloadSynchInd;
uint32_t roam_synch_data_len;
 
WMA_LOGD("LFR3:%s", __func__);
if (!event) {
......@@ -6625,6 +6626,12 @@ static int wma_roam_synch_event_handler(void *handle, u_int8_t *event, u_int32_t
return -EINVAL;
}
 
if (synch_event->vdev_id >= wma->max_bssid) {
WMA_LOGE("%s: received invalid vdev_id %d",
__func__, synch_event->vdev_id);
return -EINVAL;
}
if(wma->interfaces[synch_event->vdev_id].roam_synch_in_progress ==
VOS_TRUE) {
WMA_LOGE("%s: Ignoring RSI since one is already in progress",
......@@ -6632,29 +6639,43 @@ static int wma_roam_synch_event_handler(void *handle, u_int8_t *event, u_int32_t
return -EINVAL;
}
 
/*
* All below length fields are unsigned and hence positive numbers.
* Maximum number during the addition would be (3 * MAX_LIMIT(UINT32) +
* few fixed fields).
*/
if ((sizeof(*synch_event) + synch_event->bcn_probe_rsp_len +
synch_event->reassoc_rsp_len +
sizeof(wmi_channel) + sizeof(wmi_key_material) +
sizeof(uint32_t)) > WMA_SVC_MSG_MAX_SIZE) {
WMA_LOGE("excess synch payload: LEN bcn:%d, rsp:%d",
WMA_LOGD("synch payload: LEN bcn:%d, req:%d, rsp:%d",
synch_event->bcn_probe_rsp_len,
synch_event->reassoc_req_len,
synch_event->reassoc_rsp_len);
VOS_ASSERT(0);
if (synch_event->bcn_probe_rsp_len > WMA_SVC_MSG_MAX_SIZE)
return -EINVAL;
}
if (synch_event->reassoc_rsp_len >
(WMA_SVC_MSG_MAX_SIZE - synch_event->bcn_probe_rsp_len))
return -EINVAL;
if (synch_event->reassoc_req_len >
WMA_SVC_MSG_MAX_SIZE - (synch_event->bcn_probe_rsp_len +
synch_event->reassoc_rsp_len))
return -EINVAL;
roam_synch_data_len = synch_event->bcn_probe_rsp_len +
synch_event->reassoc_rsp_len +
synch_event->reassoc_req_len;
/*
* Below is the check for the entire size of the message received from'
* the firmware.
*/
if (roam_synch_data_len > WMA_SVC_MSG_MAX_SIZE -
(sizeof(*synch_event) + sizeof(wmi_channel) +
sizeof(wmi_key_material) + sizeof(uint32_t)))
return -EINVAL;
if (sizeof(tSirRoamOffloadSynchInd) >
(WMA_SVC_MSG_MAX_SIZE - roam_synch_data_len))
return -EINVAL;
roam_synch_data_len += sizeof(tSirRoamOffloadSynchInd);
 
adf_os_spin_lock_bh(&wma->roam_synch_lock);
wma->interfaces[synch_event->vdev_id].roam_synch_in_progress = VOS_TRUE;
adf_os_spin_unlock_bh(&wma->roam_synch_lock);
len = sizeof(tSirRoamOffloadSynchInd) +
synch_event->bcn_probe_rsp_len +
synch_event->reassoc_rsp_len;
pRoamOffloadSynchInd = (tSirRoamOffloadSynchInd *)vos_mem_malloc(len);
pRoamOffloadSynchInd =
(tSirRoamOffloadSynchInd *)vos_mem_malloc(roam_synch_data_len);
if (!pRoamOffloadSynchInd) {
WMA_LOGE("%s: failed to allocate memory for roam_synch_event", __func__);
return -ENOMEM;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment