mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-05-12 11:42:57 -04:00
Add stack size validation in SecureContext_AllocateContext
Validate that ulSecureStackSize + securecontextSTACK_SEAL_SIZE does not overflow before calling pvPortMalloc in the ARMv8-M secure context ports. Reported by Jordan Mecom (Block, Inc.)
This commit is contained in:
parent
bdcde9583d
commit
26229fd249
15 changed files with 135 additions and 30 deletions
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -213,8 +213,15 @@ secureportNON_SECURE_CALLABLE void SecureContext_Init( void )
|
|||
/* Were we able to get a free context? */
|
||||
if( ulSecureContextIndex < secureconfigMAX_SECURE_CONTEXTS )
|
||||
{
|
||||
/* Allocate the stack space. */
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
/* Allocate the stack space if possible. */
|
||||
if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) )
|
||||
{
|
||||
pucStackMemory = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE );
|
||||
}
|
||||
|
||||
if( pucStackMemory != NULL )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue