From 220771565f3e8397409a6bc7520db00e7038efe8 Mon Sep 17 00:00:00 2001 From: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:20:19 +0530 Subject: [PATCH 1/3] Removes redundant API calls in MPU wrappers (#838) * Remove redundant API calls in Queue wrappers --- portable/Common/mpu_wrappers_v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/portable/Common/mpu_wrappers_v2.c b/portable/Common/mpu_wrappers_v2.c index 30efa077338..fb4bd45fe87 100644 --- a/portable/Common/mpu_wrappers_v2.c +++ b/portable/Common/mpu_wrappers_v2.c @@ -2133,7 +2133,7 @@ if( pvItemToQueue != NULL ) { xIsItemToQueueReadable = xPortIsAuthorizedToAccessBuffer( pvItemToQueue, - uxQueueGetQueueItemSize( xInternalQueueHandle ), + uxQueueItemSize, tskMPU_READ_PERMISSION ); } @@ -2246,7 +2246,7 @@ ) { xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer, - uxQueueGetQueueItemSize( xInternalQueueHandle ), + uxQueueItemSize, tskMPU_WRITE_PERMISSION ); if( xIsReceiveBufferWritable == pdTRUE ) @@ -2298,7 +2298,7 @@ ) { xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer, - uxQueueGetQueueItemSize( xInternalQueueHandle ), + uxQueueItemSize, tskMPU_WRITE_PERMISSION ); if( xIsReceiveBufferWritable == pdTRUE ) From b32aafe4dc16cb2474e0516019c2356cd01fb1c1 Mon Sep 17 00:00:00 2001 From: Rahul Kar <118818625+kar-rahul-aws@users.noreply.github.com> Date: Thu, 19 Oct 2023 12:08:22 +0530 Subject: [PATCH 2/3] Fix size alignment in the integer overflow issue (#839) --- portable/Common/mpu_wrappers_v2.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/portable/Common/mpu_wrappers_v2.c b/portable/Common/mpu_wrappers_v2.c index fb4bd45fe87..87e849edf1b 100644 --- a/portable/Common/mpu_wrappers_v2.c +++ b/portable/Common/mpu_wrappers_v2.c @@ -113,14 +113,14 @@ #define CONVERT_TO_INTERNAL_INDEX( lIndex ) ( ( lIndex ) - INDEX_OFFSET ) /** - * @brief Max value that fits in a size_t type. + * @brief Max value that fits in a uint32_t type. */ - #define mpuSIZE_MAX ( ~( ( size_t ) 0 ) ) + #define mpuUINT32_MAX ( ~( ( uint32_t ) 0 ) ) /** * @brief Check if multiplying a and b will result in overflow. */ - #define mpuMULTIPLY_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuSIZE_MAX / ( a ) ) ) ) + #define mpuMULTIPLY_UINT32_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuUINT32_MAX / ( a ) ) ) ) /** * @brief Get the index of a free slot in the kernel object pool. @@ -1048,11 +1048,13 @@ UBaseType_t uxReturn = 0; UBaseType_t xIsTaskStatusArrayWriteable = pdFALSE; UBaseType_t xIsTotalRunTimeWriteable = pdFALSE; + uint32_t ulArraySize = ( uint32_t ) uxArraySize; + uint32_t ulTaskStatusSize = ( uint32_t ) sizeof( TaskStatus_t ); - if( mpuMULTIPLY_WILL_OVERFLOW( sizeof( TaskStatus_t ), uxArraySize ) == 0 ) + if( mpuMULTIPLY_UINT32_WILL_OVERFLOW( ulTaskStatusSize, ulArraySize ) == 0 ) { xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray, - sizeof( TaskStatus_t ) * uxArraySize, + ulTaskStatusSize * ulArraySize, tskMPU_WRITE_PERMISSION ); if( pulTotalRunTime != NULL ) @@ -1065,7 +1067,7 @@ if( ( xIsTaskStatusArrayWriteable == pdTRUE ) && ( ( pulTotalRunTime == NULL ) || ( xIsTotalRunTimeWriteable == pdTRUE ) ) ) { - uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime ); + uxReturn = uxTaskGetSystemState( pxTaskStatusArray, ( UBaseType_t ) ulArraySize, pulTotalRunTime ); } } From a936a1b156450f2454b335f711776c8cce9bc668 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Thu, 19 Oct 2023 10:08:24 -0700 Subject: [PATCH 3/3] Kernel Checker CI Workflow File Updates (#804) * Perform sparse checkout of just the .github folder for the header check instead of all the files. Update python checkout version being used. Update the version of the get changed files action being used. * Use echo groups on the header check --- .github/workflows/kernel-checks.yml | 37 +++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/kernel-checks.yml b/.github/workflows/kernel-checks.yml index 679ede23e3d..cfaec5b1213 100644 --- a/.github/workflows/kernel-checks.yml +++ b/.github/workflows/kernel-checks.yml @@ -9,10 +9,7 @@ jobs: steps: # Install python 3 - name: Tool Setup - uses: actions/setup-python@v2 - with: - python-version: 3.7.10 - architecture: x64 + uses: actions/setup-python@v3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -21,6 +18,7 @@ jobs: uses: actions/checkout@v3 with: repository: FreeRTOS/FreeRTOS + sparse-checkout: '.github' ref: main path: tools @@ -32,15 +30,40 @@ jobs: # Collect all affected files - name: Collecting changed files - uses: lots0logs/gh-action-get-changed-files@2.1.4 + uses: lots0logs/gh-action-get-changed-files@2.2.2 with: token: ${{ secrets.GITHUB_TOKEN }} # Run checks - - name: Check File Headers + - env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + stepName: Check File Headers + name: ${{ env.stepName }} + shell: bash run: | + # ${{ env.stepName }} + echo -e "::group::${{ env.bashInfo }} Install Dependencies ${{ env.bashEnd }}" + + # Copy the common tools from the FreeRTOS/FreeRTOS repo. mv tools/.github/scripts/common inspect/.github/scripts + + # Install the necessary python dependencies pip install -r inspect/.github/scripts/common/requirements.txt cd inspect + + echo -e "::group::${{ env.bashInfo }} ${{ env.stepName }} ${{ env.bashEnd }}" + + # Use the python script to check the copyright header of modified files. .github/scripts/kernel_checker.py --json ${HOME}/files_modified.json ${HOME}/files_added.json ${HOME}/files_renamed.json - exit $? + exitStatus=$? + echo -e "::endgroup::" + + if [ $exitStatus -eq 0 ]; then + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + else + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" + fi + exit $exitStatus