From a455b86bd3713707d9b762539c63fb798f2205a0 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Tue, 26 Mar 2024 22:07:11 -0700 Subject: [PATCH] Add removed unprivileged access check to ARM_CRx_MPU xPortIsAuthorizedToAccessBuffer() (#1016) * Add in a removed check for if a task is attempting to read a variable from a location it has write access to in xPortIsAuthorizedToAccessBuffer. * Add in a portDONT_DISCARD symbol as well. --- portable/GCC/ARM_CRx_MPU/port.c | 4 +++- portable/GCC/ARM_CRx_MPU/portmacro.h | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CRx_MPU/port.c b/portable/GCC/ARM_CRx_MPU/port.c index bef3a7854..e4904e58d 100644 --- a/portable/GCC/ARM_CRx_MPU/port.c +++ b/portable/GCC/ARM_CRx_MPU/port.c @@ -598,7 +598,9 @@ static BaseType_t prvMPURegionAuthorizesBuffer( const xMPU_REGION_REGISTERS * xT if( ulAccessRequested == tskMPU_READ_PERMISSION ) /* RO. */ { if( ( ulMPURegionAccessPermissions == portMPU_REGION_PRIV_RW_USER_RO ) || - ( ulMPURegionAccessPermissions == portMPU_REGION_PRIV_RO_USER_RO ) ) + ( ulMPURegionAccessPermissions == portMPU_REGION_PRIV_RO_USER_RO ) || + ( ulMPURegionAccessPermissions == portMPU_REGION_PRIV_RW_USER_RW ) ) + { xAccessGranted = pdTRUE; } diff --git a/portable/GCC/ARM_CRx_MPU/portmacro.h b/portable/GCC/ARM_CRx_MPU/portmacro.h index 4ca649f6e..7e80f093e 100644 --- a/portable/GCC/ARM_CRx_MPU/portmacro.h +++ b/portable/GCC/ARM_CRx_MPU/portmacro.h @@ -221,6 +221,13 @@ typedef uint32_t TickType_t; */ #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" ) +/** + * @brief Ensure a symbol isn't removed from the compilation unit. + * + * @ingroup Port Interface Specifications + */ +#define portDONT_DISCARD __attribute__( ( used ) ) + /** * @brief Defines if the tick count can be accessed atomically. *