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 <[email protected]>
Signed-off-by: Kishor Krishna Bhat <[email protected]>
This commit is contained in:
Naman Jain 2022-01-28 15:01:23 +05:30 • committed by Kishor Krishna Bhat
commit 501d0efe75

View file

@ -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) +