Skip to content

Commit cb95f4e

Browse files
quic-bmanojmikeNG
authored andcommitted
BACKPORT: memshare: Prevent possible integer overflow
Prevent possible integer overflow by sanitizing the alloc request size coming from the client against allottable amount of memory. Change-Id: I74cb0f7b0808f20299586969fd5c810d44c3e576 Signed-off-by: Manoj Prabhu B <quic_bmanoj@quicinc.com> Signed-off-by: Michael Bestas <mkbestas@lineageos.org>
1 parent 9c85743 commit cb95f4e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/soc/qcom/memshare/msm_memshare.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,12 @@ static int handle_alloc_generic_req(void *req_h, void *req, void *conn_h)
563563
return -EINVAL;
564564
}
565565

566-
if (!memblock[client_id].allotted) {
567-
if (alloc_req->client_id == 1 && alloc_req->num_bytes > 0)
566+
if (!memblock[client_id].allotted && alloc_req->num_bytes > 0) {
567+
568+
if (alloc_req->num_bytes > memblock[client_id].size)
569+
alloc_req->num_bytes = memblock[client_id].size;
570+
571+
if (alloc_req->client_id == 1)
568572
size = alloc_req->num_bytes + MEMSHARE_GUARD_BYTES;
569573
else
570574
size = alloc_req->num_bytes;

0 commit comments

Comments
 (0)