Skip to content

Commit 51ea2bf

Browse files
committed
Remove local stack variable form MPU wrappers
It was possible for a third party that had already independently gained the ability to execute injected code to achieve further privilege escalation by branching directly inside a FreeRTOS MPU API wrapper function with a manually crafted stack frame. This commit removes the local stack variable `xRunningPrivileged` so that a manually crafted stack frame cannot be used for privilege escalation by branching directly inside a FreeRTOS MPU API wrapper. We thank Certibit Consulting, LLC, Huazhong University of Science and Technology and the SecLab team at Northeastern University for reporting this issue. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent c4ad77f commit 51ea2bf

File tree

7 files changed

+1632
-487
lines changed

7 files changed

+1632
-487
lines changed

.github/lexicon.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,6 @@ vportgetheapstats
25332533
vportinitialiseblocks
25342534
vportisrstartfirststask
25352535
vportraisebasepri
2536-
vportresetprivilege
25372536
vportsetmpuregistersetone
25382537
vportsetuptimerinterrupt
25392538
vportstartfirststask
@@ -2852,7 +2851,6 @@ xperiod
28522851
xportgetcoreid
28532852
xportgetfreeheapsize
28542853
xportinstallinterrupthandler
2855-
xportraiseprivilege
28562854
xportregistercinterrupthandler
28572855
xportregisterdump
28582856
xportstartfirsttask

include/mpu_wrappers.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -170,36 +170,6 @@
170170
#define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
171171
#define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) )
172172

173-
/**
174-
* @brief Calls the port specific code to raise the privilege.
175-
*
176-
* Sets xRunningPrivileged to pdFALSE if privilege was raised, else sets
177-
* it to pdTRUE.
178-
*/
179-
#define xPortRaisePrivilege( xRunningPrivileged ) \
180-
{ \
181-
/* Check whether the processor is already privileged. */ \
182-
xRunningPrivileged = portIS_PRIVILEGED(); \
183-
\
184-
/* If the processor is not already privileged, raise privilege. */ \
185-
if( xRunningPrivileged == pdFALSE ) \
186-
{ \
187-
portRAISE_PRIVILEGE(); \
188-
} \
189-
}
190-
191-
/**
192-
* @brief If xRunningPrivileged is not pdTRUE, calls the port specific
193-
* code to reset the privilege, otherwise does nothing.
194-
*/
195-
#define vPortResetPrivilege( xRunningPrivileged ) \
196-
{ \
197-
if( xRunningPrivileged == pdFALSE ) \
198-
{ \
199-
portRESET_PRIVILEGE(); \
200-
} \
201-
}
202-
203173
#endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
204174

205175
#else /* portUSING_MPU_WRAPPERS */

0 commit comments

Comments
 (0)