Skip to content

fix: TOCTOU race condition in vTaskListTasks() + add .editorconfig#1409

Open
srpatcha wants to merge 5 commits intoFreeRTOS:mainfrom
srpatcha:chore/add-editorconfig
Open

fix: TOCTOU race condition in vTaskListTasks() + add .editorconfig#1409
srpatcha wants to merge 5 commits intoFreeRTOS:mainfrom
srpatcha:chore/add-editorconfig

Conversation

@srpatcha
Copy link
Copy Markdown

@srpatcha srpatcha commented Apr 25, 2026

Changes

1. Add .editorconfig for consistent code formatting

Adds a standard .editorconfig file to ensure consistent formatting across editors.

2. Fix TOCTOU race condition in vTaskListTasks() (tasks.c)

vTaskListTasks() reads the volatile uxCurrentNumberOfTasks variable twice — once to set uxArraySize and again for the pvPortMalloc() call. If a task is created between the two reads, the allocated buffer is too small for the data written by uxTaskGetSystemState(), causing a buffer overflow.

Fix: Use the local uxArraySize variable (already captured) for both the size check and the malloc call.

Enforce consistent 4-space indentation for C source files
and proper line ending handling.
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().
@srpatcha srpatcha changed the title chore: add .editorconfig for consistent code formatting fix: TOCTOU race condition in vTaskListTasks() + add .editorconfig Apr 25, 2026
Signed-off-by: Srikanth Patchava <spatchava@meta.com>
Signed-off-by: Srikanth Patchava <spatchava@meta.com>
Signed-off-by: Srikanth Patchava <spatchava@meta.com>
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant