feat: Automatic MPU ACL cleanup on object deletion (#1499)

Signed-off-by: Ian Chang <ian0318@gmail.com>
This commit is contained in:
Ian Chang 2026-10-04 23:01:07 +11:00
parent 8be86d4a24
commit 88e562250b
6 changed files with 50 additions and 0 deletions

View file

@ -693,6 +693,12 @@
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
{
vvMPU_ObjectDeleted( ( int32_t ) xEventGroup );
}
#endif
traceRETURN_vEventGroupDelete();
}
/*-----------------------------------------------------------*/

View file

@ -85,6 +85,12 @@
#define configENABLE_ACCESS_CONTROL_LIST 0
#endif
/* Set configENABLE_AUTOMATIC_ACL_CLEANUP to 1 to automatically revoke ACL
* permissions on object deletion. */
#ifndef configENABLE_AUTOMATIC_ACL_CLEANUP
#define configENABLE_AUTOMATIC_ACL_CLEANUP 0
#endif
/* Set default value of configNUMBER_OF_CORES to 1 to use single core FreeRTOS. */
#ifndef configNUMBER_OF_CORES
#define configNUMBER_OF_CORES 1

View file

@ -278,6 +278,11 @@
#endif /* #if ( ( configUSE_MPU_WRAPPERS_V1 == 0 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) ) */
#if ( configUSE_MPU_WRAPPERS_V1 == 0 )
void vvMPU_ObjectDeleted( int32_t lExternalKernelObjectHandle ) PRIVILEGED_FUNCTION;
#endif
#endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
#define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) )

View file

@ -47,6 +47,21 @@
#include "mpu_syscall_numbers.h"
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
void vvMPU_ObjectDeleted( int32_t lExternalKernelObjectHandle ) /* PRIVILEGED_FUNCTION */
{
if( IS_EXTERNAL_INDEX_VALID( lExternalKernelObjectHandle ) != pdFALSE )
{
#if ( configENABLE_AUTOMATIC_ACL_CLEANUP == 1 )
{
vRevokeAccessToKernelObject( NULL, lExternalKernelObjectHandle );
}
#endif
MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
}
}
/*-----------------------------------------------------------*/
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )

12
queue.c
View file

@ -2298,6 +2298,18 @@ void vQueueDelete( QueueHandle_t xQueue )
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
{
vvMPU_ObjectDeleted( ( int32_t ) xQueue );
}
#endif
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
{
vvMPU_ObjectDeleted( ( int32_t ) xQueue );
}
#endif
traceRETURN_vQueueDelete();
}
/*-----------------------------------------------------------*/

View file

@ -596,6 +596,12 @@ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer )
( void ) memset( pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) );
}
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configENABLE_ACCESS_CONTROL_LIST == 1 ) )
{
vvMPU_ObjectDeleted( ( int32_t ) xStreamBuffer );
}
#endif
traceRETURN_vStreamBufferDelete();
}
/*-----------------------------------------------------------*/