Skip to content

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

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

fix: TOCTOU race condition in vTaskListTasks() + add .editorconfig#1409
srpatcha wants to merge 5 commits into
FreeRTOS: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.

@srpatcha srpatcha changed the title chore: add .editorconfig for consistent code formatting fix: TOCTOU race condition in vTaskListTasks() + add .editorconfig Apr 25, 2026
srpatcha and others added 5 commits May 11, 2026 13:09
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().
Signed-off-by: Srikanth Patchava <spatchava@meta.com>
Signed-off-by: Srikanth Patchava <spatchava@meta.com>
Signed-off-by: Srikanth Patchava <spatchava@meta.com>
@srpatcha srpatcha force-pushed the chore/add-editorconfig branch from 3f8748d to 6f2a4b5 Compare May 11, 2026 20:09
@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