Browse Source

fix(el3-spmc): improve bound check for descriptor

Ensure that there is sufficient space in the memory
descriptor to accommodate the size of the composite memory
struct as part of the descriptor.

Signed-off-by: Marc Bonnici <marc.bonnici@arm.com>
Change-Id: Iea646b144c59a2a1a171298cabb5f31040a8af31
pull/1992/head
Marc Bonnici 2 years ago
committed by Shruti Gupta
parent
commit
def7590b3e
  1. 6
      services/std_svc/spm/el3_spmc/spmc_shared_mem.c

6
services/std_svc/spm/el3_spmc/spmc_shared_mem.c

@ -385,7 +385,8 @@ spmc_shm_get_v1_1_descriptor_size(struct ffa_mtd_v1_0 *orig, size_t desc_size)
emad_array[0].comp_mrd_offset);
/* Check the calculated address is within the memory descriptor. */
if ((uintptr_t) mrd >= (uintptr_t)((uint8_t *) orig + desc_size)) {
if (((uintptr_t) mrd + sizeof(struct ffa_comp_mrd)) >
(uintptr_t)((uint8_t *) orig + desc_size)) {
return 0;
}
size += mrd->address_range_count * sizeof(struct ffa_cons_mrd);
@ -424,7 +425,8 @@ spmc_shm_get_v1_0_descriptor_size(struct ffa_mtd *orig, size_t desc_size)
emad_array[0].comp_mrd_offset);
/* Check the calculated address is within the memory descriptor. */
if ((uintptr_t) mrd >= (uintptr_t)((uint8_t *) orig + desc_size)) {
if (((uintptr_t) mrd + sizeof(struct ffa_comp_mrd)) >
(uintptr_t)((uint8_t *) orig + desc_size)) {
return 0;
}
size += mrd->address_range_count * sizeof(struct ffa_cons_mrd);

Loading…
Cancel
Save