Skip to content

Commit d9fc48b

Browse files
Backport PR 839 to FreeRTOS-Kernel V10.6.1 (#840)
* Fix size alignment in the integer overflow issue * Remove CORTEX_M3_MPS2_QEMU demo in the V10.6.x branch to sync with the main branch.
1 parent 7003ba7 commit d9fc48b

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

.github/workflows/kernel-demos.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,6 @@ jobs:
161161
working-directory: FreeRTOS/Demo/CORTEX_LM3S102_GCC
162162
run: make -j
163163

164-
- name: Build CORTEX_M3_MPS2_QEMU_GCC Demo
165-
shell: bash
166-
working-directory: FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC
167-
run: |
168-
make clean
169-
make -j
170-
171-
- name: Build CORTEX_M3_MPS2_QEMU_GCC Demo
172-
shell: bash
173-
working-directory: FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC
174-
run: |
175-
make clean
176-
make FULL_DEMO=1 -j
177-
178164
- name: Build CORTEX_LM3S811_GCC Demo
179165
shell: bash
180166
working-directory: FreeRTOS/Demo/CORTEX_LM3S811_GCC

portable/Common/mpu_wrappers_v2.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@
113113
#define CONVERT_TO_INTERNAL_INDEX( lIndex ) ( ( lIndex ) - INDEX_OFFSET )
114114

115115
/**
116-
* @brief Max value that fits in a size_t type.
116+
* @brief Max value that fits in a uint32_t type.
117117
*/
118-
#define mpuSIZE_MAX ( ~( ( size_t ) 0 ) )
118+
#define mpuUINT32_MAX ( ~( ( uint32_t ) 0 ) )
119119

120120
/**
121121
* @brief Check if multiplying a and b will result in overflow.
122122
*/
123-
#define mpuMULTIPLY_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuSIZE_MAX / ( a ) ) ) )
123+
#define mpuMULTIPLY_UINT32_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuUINT32_MAX / ( a ) ) ) )
124124

125125
/**
126126
* @brief Get the index of a free slot in the kernel object pool.
@@ -937,11 +937,13 @@
937937
UBaseType_t uxReturn = 0;
938938
UBaseType_t xIsTaskStatusArrayWriteable = pdFALSE;
939939
UBaseType_t xIsTotalRunTimeWriteable = pdFALSE;
940+
uint32_t ulArraySize = ( uint32_t ) uxArraySize;
941+
uint32_t ulTaskStatusSize = ( uint32_t ) sizeof( TaskStatus_t );
940942

941-
if( mpuMULTIPLY_WILL_OVERFLOW( sizeof( TaskStatus_t ), uxArraySize ) == 0 )
943+
if( mpuMULTIPLY_UINT32_WILL_OVERFLOW( ulTaskStatusSize, ulArraySize ) == 0 )
942944
{
943945
xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray,
944-
sizeof( TaskStatus_t ) * uxArraySize,
946+
ulTaskStatusSize * ulArraySize,
945947
tskMPU_WRITE_PERMISSION );
946948

947949
if( pulTotalRunTime != NULL )
@@ -954,7 +956,7 @@
954956
if( ( xIsTaskStatusArrayWriteable == pdTRUE ) &&
955957
( ( pulTotalRunTime == NULL ) || ( xIsTotalRunTimeWriteable == pdTRUE ) ) )
956958
{
957-
uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
959+
uxReturn = uxTaskGetSystemState( pxTaskStatusArray, ( UBaseType_t ) ulArraySize, pulTotalRunTime );
958960
}
959961
}
960962

0 commit comments

Comments
 (0)