From afe62624c313b78778d4bb4962f5141ac5a0b728 Mon Sep 17 00:00:00 2001 From: Sandrine Bailleux Date: Thu, 2 Apr 2020 15:52:44 +0200 Subject: [PATCH] Check for out-of-bound accesses in the platform io policies The platform io policies array is now always accessed through a fconf getter. This gives us an ideal spot to check for out-of-bound accesses. Remove the assertion in plat_get_image_source(), which is now redundant. Change-Id: Iefe808d530229073b68cbd164d927b8b6662a217 Signed-off-by: Sandrine Bailleux --- include/plat/arm/common/arm_fconf_getter.h | 7 ++++++- plat/arm/common/arm_io_storage.c | 4 ---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/plat/arm/common/arm_fconf_getter.h b/include/plat/arm/common/arm_fconf_getter.h index 28913a43f..8fd8c7ada 100644 --- a/include/plat/arm/common/arm_fconf_getter.h +++ b/include/plat/arm/common/arm_fconf_getter.h @@ -7,10 +7,15 @@ #ifndef ARM_FCONF_GETTER #define ARM_FCONF_GETTER +#include + #include /* ARM io policies */ -#define arm__io_policies_getter(id) &policies[id] +#define arm__io_policies_getter(id) __extension__ ({ \ + assert((id) < MAX_NUMBER_IDS); \ + &policies[id]; \ +}) struct plat_io_policy { uintptr_t *dev_handle; diff --git a/plat/arm/common/arm_io_storage.c b/plat/arm/common/arm_io_storage.c index 6fcfbd6fb..34b4101e1 100644 --- a/plat/arm/common/arm_io_storage.c +++ b/plat/arm/common/arm_io_storage.c @@ -4,8 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include - #include #include #include @@ -116,8 +114,6 @@ int plat_get_image_source(unsigned int image_id, uintptr_t *dev_handle, int result; const struct plat_io_policy *policy; - assert(image_id < MAX_NUMBER_IDS); - policy = FCONF_GET_PROPERTY(arm, io_policies, image_id); result = policy->check(policy->image_spec); if (result == 0) { -- GitLab