Skip to content

Commit 7a98bd8

Browse files
committed
Added checks for xIndex in ThreadLocalStorage APIs
It was possible for a third party that already independently gained the ability to execute injected code to read from or write to arbitrary addresses by passing a negative argument as the xIndex parameter to pvTaskGetThreadLocalStoragePointer() or vTaskSetThreadLocalStoragePointer respectively. This commit adds checks to ensure that passing a negative argument as the xIndex parameter does not cause arbitrary read or write. We thank Certibit Consulting, LLC for reporting this issue. Signed-off-by: Gaurav Aggarwal <[email protected]>
1 parent da73aa6 commit 7a98bd8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tasks.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3600,7 +3600,8 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
36003600
{
36013601
TCB_t * pxTCB;
36023602

3603-
if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )
3603+
if( ( xIndex >= 0 ) &&
3604+
( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) )
36043605
{
36053606
pxTCB = prvGetTCBFromHandle( xTaskToSet );
36063607
configASSERT( pxTCB != NULL );
@@ -3619,7 +3620,8 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
36193620
void * pvReturn = NULL;
36203621
TCB_t * pxTCB;
36213622

3622-
if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )
3623+
if( ( xIndex >= 0 ) &&
3624+
( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS ) )
36233625
{
36243626
pxTCB = prvGetTCBFromHandle( xTaskToQuery );
36253627
pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ];

0 commit comments

Comments
 (0)