Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/template_configuration/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,13 @@
* provided for the same. Defaults to 0 if left undefined. */
#define configENABLE_ACCESS_CONTROL_LIST 1

/* When using the v2 MPU wrapper with Access Control Lists enabled, set
* configENABLE_ACL_OBJECT_DELETION_CLEANUP to 1 to automatically remove
* access permissions to the object upon deletion. If this is not enabled,
* the privileged task calling the deletion API has the responsibility to
* clean up the ACLs. */
#define configENABLE_ACL_OBJECT_DELETION_CLEANUP 0

/******************************************************************************/
/* SMP( Symmetric MultiProcessing ) Specific Configuration definitions. *******/
/******************************************************************************/
Expand Down
60 changes: 60 additions & 0 deletions portable/Common/mpu_wrappers_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,34 @@
}
/*-----------------------------------------------------------*/

#if ( ( configENABLE_ACCESS_CONTROL_LIST == 1 ) && ( configENABLE_ACL_OBJECT_DELETION_CLEANUP == 1 ) )

static void vRevokeAccessObjectDeleted( int32_t lExternalIndexOfKernelObject ) /* PRIVILEGED_FUNCTION */
{
int32_t i;
TaskHandle_t xInternalTaskHandle;

if( IS_EXTERNAL_INDEX_VALID( lExternalIndexOfKernelObject ) != pdFALSE )
{
for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ )
{
if( xKernelObjectPool[ i ].ulKernelObjectType == KERNEL_OBJECT_TYPE_TASK )
{
xInternalTaskHandle = ( TaskHandle_t ) xKernelObjectPool[ i ].xInternalObjectHandle;

if( xInternalTaskHandle != NULL )
{
vPortRevokeAccessToKernelObject( xInternalTaskHandle,
CONVERT_TO_INTERNAL_INDEX( lExternalIndexOfKernelObject ) );
}
}
}
}
}

#endif /* #if ( ( configENABLE_ACCESS_CONTROL_LIST == 1 ) && ( configENABLE_ACL_OBJECT_DELETION_CLEANUP == 1 ) ) */
/*-----------------------------------------------------------*/

#if ( configENABLE_ACCESS_CONTROL_LIST == 1 )

void vGrantAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
Expand Down Expand Up @@ -1648,6 +1676,12 @@

if( lIndex != -1 )
{
#if ( ( configENABLE_ACCESS_CONTROL_LIST == 1 ) && ( configENABLE_ACL_OBJECT_DELETION_CLEANUP == 1 ) )
{
vRevokeAccessObjectDeleted( CONVERT_TO_EXTERNAL_INDEX( lIndex ) );
}
#endif

MPU_SetIndexFreeInKernelObjectPool( lIndex );
}

Expand All @@ -1663,6 +1697,12 @@

if( xInternalTaskHandle != NULL )
{
#if ( ( configENABLE_ACCESS_CONTROL_LIST == 1 ) && ( configENABLE_ACL_OBJECT_DELETION_CLEANUP == 1 ) )
{
vRevokeAccessObjectDeleted( lIndex );
}
#endif

MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
vTaskDelete( xInternalTaskHandle );
}
Expand Down Expand Up @@ -2760,6 +2800,13 @@
if( xInternalQueueHandle != NULL )
{
vQueueDelete( xInternalQueueHandle );

#if ( ( configENABLE_ACCESS_CONTROL_LIST == 1 ) && ( configENABLE_ACL_OBJECT_DELETION_CLEANUP == 1 ) )
{
vRevokeAccessObjectDeleted( lIndex );
}
#endif

MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
}
}
Expand Down Expand Up @@ -4247,6 +4294,13 @@
if( xInternalEventGroupHandle != NULL )
{
vEventGroupDelete( xInternalEventGroupHandle );

#if ( ( configENABLE_ACCESS_CONTROL_LIST == 1 ) && ( configENABLE_ACL_OBJECT_DELETION_CLEANUP == 1 ) )
{
vRevokeAccessObjectDeleted( lIndex );
}
#endif

MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
}
}
Expand Down Expand Up @@ -4810,6 +4864,12 @@
if( xInternalStreamBufferHandle != NULL )
{
vStreamBufferDelete( xInternalStreamBufferHandle );

#if ( ( configENABLE_ACCESS_CONTROL_LIST == 1 ) && ( configENABLE_ACL_OBJECT_DELETION_CLEANUP == 1 ) )
{
vRevokeAccessObjectDeleted( lIndex );
}
#endif
}

MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
Expand Down
Loading