From 501d0efe7525de1456b444a6f7f30b50a0d22582 Mon Sep 17 00:00:00 2001 From: Naman Jain Date: Fri, 28 Jan 2022 15:01:23 +0530 Subject: [PATCH] haven: hh_rm_iface: Avoid integer overflow for multiplication Add a check to ensure that overflow does not happen in multiplication operation. Change-Id: I28ea55c760257775c1bec3fdfb373fe075190cab Signed-off-by: Naman Jain Signed-off-by: Kishor Krishna Bhat --- drivers/virt/haven/hh_rm_iface.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/virt/haven/hh_rm_iface.c b/drivers/virt/haven/hh_rm_iface.c index ea8ab935d736..bc3559602b2b 100644 --- a/drivers/virt/haven/hh_rm_iface.c +++ b/drivers/virt/haven/hh_rm_iface.c @@ -121,6 +121,8 @@ hh_rm_vm_get_hyp_res(hh_vmid_t vmid, u32 *n_entries) /* The response payload should contain all the resource entries */ if (resp_payload_size < sizeof(*n_entries) || + (sizeof(*resp_entries) && + (resp_payload->n_resource_entries > U32_MAX / sizeof(*resp_entries))) || (sizeof(*n_entries) > (U32_MAX - (resp_payload->n_resource_entries * sizeof(*resp_entries)))) || resp_payload_size != sizeof(*n_entries) +