mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-06-20 10:03:43 +02:00
fix: TOCTOU race condition in vTaskListTasks()
Read uxCurrentNumberOfTasks once into uxArraySize and use that local variable for both the size check and pvPortMalloc() call. The previous code read the volatile variable twice, allowing a task to be created between the reads, resulting in an undersized allocation that could cause a buffer overflow in uxTaskGetSystemState().
This commit is contained in:
parent
83e56c38ee
commit
e146d6444c
4
tasks.c
4
tasks.c
@ -7362,7 +7362,7 @@ STATIC void prvResetNextTaskUnblockTime( void )
|
|||||||
/* MISRA Ref 11.5.1 [Malloc memory assignment] */
|
/* MISRA Ref 11.5.1 [Malloc memory assignment] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */
|
||||||
/* coverity[misra_c_2012_rule_11_5_violation] */
|
/* coverity[misra_c_2012_rule_11_5_violation] */
|
||||||
pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );
|
pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
|
||||||
|
|
||||||
if( pxTaskStatusArray != NULL )
|
if( pxTaskStatusArray != NULL )
|
||||||
{
|
{
|
||||||
@ -7531,7 +7531,7 @@ STATIC void prvResetNextTaskUnblockTime( void )
|
|||||||
/* MISRA Ref 11.5.1 [Malloc memory assignment] */
|
/* MISRA Ref 11.5.1 [Malloc memory assignment] */
|
||||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */
|
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */
|
||||||
/* coverity[misra_c_2012_rule_11_5_violation] */
|
/* coverity[misra_c_2012_rule_11_5_violation] */
|
||||||
pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );
|
pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
|
||||||
|
|
||||||
if( pxTaskStatusArray != NULL )
|
if( pxTaskStatusArray != NULL )
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user