Skip to content

Commit

Permalink
icnss: Add check on msa region
Browse files Browse the repository at this point in the history
When icnss receive server arrive it send wlfw_msa_mem_info_send_sync_msg
QMI request to firmware and in response expect range of addresses and size
to be mapped. Add condition to check whether addresses in response falls
under valid range otherwise it asserts.

Change-Id: I9a8542cb6c3b3cefe112d1f08a76dd2eadf68d2f
Signed-off-by: Naman Padhiar <[email protected]>
  • Loading branch information
Naman Padhiar authored and jb-essential committed Jul 2, 2019
1 parent e7c726d commit 401a2d0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/soc/qcom/icnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@ static int wlfw_msa_mem_info_send_sync_msg(void)
struct wlfw_msa_info_req_msg_v01 req;
struct wlfw_msa_info_resp_msg_v01 resp;
struct msg_desc req_desc, resp_desc;
uint64_t max_mapped_addr;

if (!penv || !penv->wlfw_clnt)
return -ENODEV;
Expand Down Expand Up @@ -1267,9 +1268,23 @@ static int wlfw_msa_mem_info_send_sync_msg(void)
goto out;
}

max_mapped_addr = penv->msa_pa + penv->msa_mem_size;
penv->stats.msa_info_resp++;
penv->nr_mem_region = resp.mem_region_info_len;
for (i = 0; i < resp.mem_region_info_len; i++) {

if (resp.mem_region_info[i].size > penv->msa_mem_size ||
resp.mem_region_info[i].region_addr > max_mapped_addr ||
resp.mem_region_info[i].region_addr < penv->msa_pa ||
resp.mem_region_info[i].size +
resp.mem_region_info[i].region_addr > max_mapped_addr) {
icnss_pr_dbg("Received out of range Addr: 0x%llx Size: 0x%x\n",
resp.mem_region_info[i].region_addr,
resp.mem_region_info[i].size);
ret = -EINVAL;
goto fail_unwind;
}

penv->mem_region[i].reg_addr =
resp.mem_region_info[i].region_addr;
penv->mem_region[i].size =
Expand All @@ -1284,6 +1299,8 @@ static int wlfw_msa_mem_info_send_sync_msg(void)

return 0;

fail_unwind:
memset(&penv->mem_region[0], 0, sizeof(penv->mem_region[0]) * i);
out:
penv->stats.msa_info_err++;
ICNSS_QMI_ASSERT();
Expand Down

0 comments on commit 401a2d0

Please sign in to comment.