mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-10-09 23:53:04 -04:00
Allow start scheduler and free context SVC from privileged code only (#1475)
Allow start scheduler and free context SVC from privileged code only Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
a0e2097c6a
commit
3ca84562d8
44 changed files with 1717 additions and 799 deletions
|
|
@ -290,9 +290,12 @@ secureportNON_SECURE_CALLABLE void SecureContext_FreeContext( SecureContextHandl
|
|||
void * pvTaskHandle )
|
||||
{
|
||||
uint32_t ulIPSR, ulSecureContextIndex;
|
||||
uint8_t * pucStackLimit;
|
||||
|
||||
/* Read the Interrupt Program Status Register (IPSR) value. */
|
||||
/* Read the Interrupt Program Status Register (IPSR) and Process Stack Limit
|
||||
* Register (PSPLIM) value. */
|
||||
secureportREAD_IPSR( ulIPSR );
|
||||
secureportREAD_PSPLIM( pucStackLimit );
|
||||
|
||||
/* Do nothing if the processor is running in the Thread Mode. IPSR is zero
|
||||
* when the processor is running in the Thread Mode. */
|
||||
|
|
@ -304,8 +307,14 @@ secureportNON_SECURE_CALLABLE void SecureContext_FreeContext( SecureContextHandl
|
|||
ulSecureContextIndex = xSecureContextHandle - 1UL;
|
||||
|
||||
/* Ensure that the secure context being deleted is associated with
|
||||
* the task. */
|
||||
if( xSecureContexts[ ulSecureContextIndex ].pvTaskHandle == pvTaskHandle )
|
||||
* the task and is NOT the currently-loaded context. Freeing a
|
||||
* context whose stack is currently loaded in PSPLIM would leave the
|
||||
* running task referencing freed secure memory (use-after-free).
|
||||
* pvTaskHandle is supplied by the non-secure side and is untrusted,
|
||||
* so it is used only as an additional ownership match, not as
|
||||
* authority. */
|
||||
if( ( xSecureContexts[ ulSecureContextIndex ].pvTaskHandle == pvTaskHandle ) &&
|
||||
( xSecureContexts[ ulSecureContextIndex ].pucStackLimit != pucStackLimit ) )
|
||||
{
|
||||
/* Free the stack space. */
|
||||
vPortFree( xSecureContexts[ ulSecureContextIndex ].pucStackLimit );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue