Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed buffer underflow in prvSelectHighestPriorityTask. #607

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/kernel-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Tool Setup
uses: actions/setup-python@v2
with:
python-version: 3.7.10
python-version: 3.11.0
architecture: x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 6 additions & 2 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,9 @@ static void prvYieldForTask( TCB_t * pxTCB,
{
if( xDecrementTopPriority != pdFALSE )
{
uxTopReadyPriority--;
if(uxTopReadyPriority > 0) {
uxTopReadyPriority--;
}
Comment on lines +941 to +943
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit pick, non-blocking: I realize 0 isn't exactly a magic number in this context BUT I would prefer this line to say uxTopReadyPriority > tskIDLE_PRIORITY. This would read like "The Top Ready Priority cannot be less than the idle task" rather than "The Top Ready Priority cannot be less than 0". While these are functionally the same, pinning this to the idle task would make it clearer that no task can be lower in priority than the idle task.

Comment on lines +941 to +943
Copy link
Member

@AniruddhaKanhere AniruddhaKanhere Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting should be something like the following (to adhere to the Kernel's formatting style)

Suggested change
if(uxTopReadyPriority > 0) {
uxTopReadyPriority--;
}
/* The top ready priority cannot be less than the idle task's priority. */
if( uxTopReadyPriority > tskIDLE_PRIORITY )
{
uxTopReadyPriority--;
}

#if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )
{
xPriorityDropped = pdTRUE;
Expand All @@ -956,7 +958,9 @@ static void prvYieldForTask( TCB_t * pxTCB,
}

configASSERT( ( uxCurrentPriority > tskIDLE_PRIORITY ) || ( xTaskScheduled == pdTRUE ) );
uxCurrentPriority--;
if(uxCurrentPriority > 0) {
uxCurrentPriority--;
}
Comment on lines +961 to +963
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here as well

Suggested change
if(uxCurrentPriority > 0) {
uxCurrentPriority--;
}
/* The top ready priority cannot be less than the idle task's priority. */
if( uxCurrentPriority > tskIDLE_PRIORITY )
{
uxCurrentPriority--;
}

}

configASSERT( taskTASK_IS_RUNNING( pxCurrentTCBs[ xCoreID ]->xTaskRunState ) );
Expand Down