4141#define TX_THREAD_SECURE_STACK_MAXIMUM 1024
4242#endif
4343
44+ /* 8 bytes added to stack size to "seal" stack. */
45+ #define TX_THREAD_STACK_SEAL_SIZE 8
46+ #define TX_THREAD_STACK_SEAL_VALUE 0xFEF5EDA5
47+
4448/* Secure stack info struct to hold stack start, stack limit,
4549 current stack pointer, and pointer to owning thread.
4650 This will be allocated for each thread with a secure stack. */
@@ -59,7 +63,7 @@ typedef struct TX_THREAD_SECURE_STACK_INFO_STRUCT
5963/* FUNCTION RELEASE */
6064/* */
6165/* _tx_thread_secure_stack_initialize Cortex-M23/AC5 */
62- /* 6.1 */
66+ /* 6.1.1 */
6367/* AUTHOR */
6468/* */
6569/* Scott Larson, Microsoft Corporation */
@@ -91,7 +95,9 @@ typedef struct TX_THREAD_SECURE_STACK_INFO_STRUCT
9195/* */
9296/* DATE NAME DESCRIPTION */
9397/* */
94- /* 09-30-2020 Scott Larson Initial Version 6.1 */
98+ /* 09-30-2020 Scott Larson Initial Version 6.1 */
99+ /* 10-16-2020 Scott Larson Modified comment(s), */
100+ /* resulting in version 6.1.1 */
95101/* */
96102/**************************************************************************/
97103__attribute__((cmse_nonsecure_entry ))
@@ -116,7 +122,7 @@ void _tx_thread_secure_stack_initialize(void)
116122/* FUNCTION RELEASE */
117123/* */
118124/* _tx_thread_secure_mode_stack_allocate Cortex-M23/AC5 */
119- /* 6.1 */
125+ /* 6.1.1 */
120126/* AUTHOR */
121127/* */
122128/* Scott Larson, Microsoft Corporation */
@@ -155,7 +161,10 @@ void _tx_thread_secure_stack_initialize(void)
155161/* */
156162/* DATE NAME DESCRIPTION */
157163/* */
158- /* 09-30-2020 Scott Larson Initial Version 6.1 */
164+ /* 09-30-2020 Scott Larson Initial Version 6.1 */
165+ /* 10-16-2020 Scott Larson Modified comment(s), */
166+ /* added stack sealing, */
167+ /* resulting in version 6.1.1 */
159168/* */
160169/**************************************************************************/
161170__attribute__((cmse_nonsecure_entry ))
@@ -191,8 +200,8 @@ ULONG sp;
191200
192201 if (info_ptr != TX_NULL )
193202 {
194- /* If stack info allocated, allocate a stack. */
195- stack_mem = malloc (stack_size );
203+ /* If stack info allocated, allocate a stack & seal . */
204+ stack_mem = malloc (stack_size + TX_THREAD_STACK_SEAL_SIZE );
196205
197206 if (stack_mem != TX_NULL )
198207 {
@@ -202,6 +211,9 @@ ULONG sp;
202211 info_ptr -> tx_thread_secure_stack_ptr = info_ptr -> tx_thread_secure_stack_start ;
203212 info_ptr -> tx_thread_ptr = thread_ptr ;
204213
214+ /* Seal bottom of stack. */
215+ * (ULONG * )info_ptr -> tx_thread_secure_stack_start = TX_THREAD_STACK_SEAL_VALUE ;
216+
205217 /* Save info pointer in thread. */
206218 thread_ptr -> tx_thread_secure_stack_context = info_ptr ;
207219
@@ -240,7 +252,7 @@ ULONG sp;
240252/* FUNCTION RELEASE */
241253/* */
242254/* _tx_thread_secure_mode_stack_free Cortex-M23/AC5 */
243- /* 6.1 */
255+ /* 6.1.1 */
244256/* AUTHOR */
245257/* */
246258/* Scott Larson, Microsoft Corporation */
@@ -272,7 +284,9 @@ ULONG sp;
272284/* */
273285/* DATE NAME DESCRIPTION */
274286/* */
275- /* 09-30-2020 Scott Larson Initial Version 6.1 */
287+ /* 09-30-2020 Scott Larson Initial Version 6.1 */
288+ /* 10-16-2020 Scott Larson Modified comment(s), */
289+ /* resulting in version 6.1.1 */
276290/* */
277291/**************************************************************************/
278292__attribute__((cmse_nonsecure_entry ))
@@ -321,7 +335,7 @@ TX_THREAD_SECURE_STACK_INFO *info_ptr;
321335/* FUNCTION RELEASE */
322336/* */
323337/* _tx_thread_secure_stack_context_save Cortex-M23/AC5 */
324- /* 6.1 */
338+ /* 6.1.1 */
325339/* AUTHOR */
326340/* */
327341/* Scott Larson, Microsoft Corporation */
@@ -353,7 +367,9 @@ TX_THREAD_SECURE_STACK_INFO *info_ptr;
353367/* */
354368/* DATE NAME DESCRIPTION */
355369/* */
356- /* 09-30-2020 Scott Larson Initial Version 6.1 */
370+ /* 09-30-2020 Scott Larson Initial Version 6.1 */
371+ /* 10-16-2020 Scott Larson Modified comment(s), */
372+ /* resulting in version 6.1.1 */
357373/* */
358374/**************************************************************************/
359375__attribute__((cmse_nonsecure_entry ))
@@ -403,7 +419,7 @@ ULONG sp;
403419/* FUNCTION RELEASE */
404420/* */
405421/* _tx_thread_secure_stack_context_restore Cortex-M23/AC5 */
406- /* 6.1 */
422+ /* 6.1.1 */
407423/* AUTHOR */
408424/* */
409425/* Scott Larson, Microsoft Corporation */
@@ -434,7 +450,9 @@ ULONG sp;
434450/* */
435451/* DATE NAME DESCRIPTION */
436452/* */
437- /* 09-30-2020 Scott Larson Initial Version 6.1 */
453+ /* 09-30-2020 Scott Larson Initial Version 6.1 */
454+ /* 10-16-2020 Scott Larson Modified comment(s), */
455+ /* resulting in version 6.1.1 */
438456/* */
439457/**************************************************************************/
440458__attribute__((cmse_nonsecure_entry ))
0 commit comments