Add stack size validation in SecureContext_AllocateContext#1402
Merged
patrzhan merged 1 commit intoFreeRTOS:mainfrom Apr 16, 2026
Merged
Add stack size validation in SecureContext_AllocateContext#1402patrzhan merged 1 commit intoFreeRTOS:mainfrom
patrzhan merged 1 commit intoFreeRTOS:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1402 +/- ##
==========================================
- Coverage 91.46% 91.37% -0.09%
==========================================
Files 6 6
Lines 3256 3259 +3
Branches 899 902 +3
==========================================
Hits 2978 2978
Misses 132 132
- Partials 146 149 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
kstribrnAmzn
previously approved these changes
Apr 16, 2026
f259a60 to
baaac7d
Compare
kstribrnAmzn
previously approved these changes
Apr 16, 2026
Comment on lines
+216
to
+224
| /* Allocate the stack space if possible. */ | ||
| if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) ) | ||
| { | ||
| pucStackMemory = NULL; | ||
| } | ||
| else | ||
| { | ||
| pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE ); | ||
| } |
Member
There was a problem hiding this comment.
Formatting is incorrect across all the changes. We are probably not running formatter for ports. Can you please fix this?
Suggested change
| /* Allocate the stack space if possible. */ | |
| if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) ) | |
| { | |
| pucStackMemory = NULL; | |
| } | |
| else | |
| { | |
| pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE ); | |
| } | |
| /* Allocate the stack space if possible. */ | |
| if( ulSecureStackSize > ( UINT32_MAX - securecontextSTACK_SEAL_SIZE ) ) | |
| { | |
| pucStackMemory = NULL; | |
| } | |
| else | |
| { | |
| pucStackMemory = pvPortMalloc( ulSecureStackSize + securecontextSTACK_SEAL_SIZE ); | |
| } |
Validate that ulSecureStackSize + securecontextSTACK_SEAL_SIZE does not overflow before calling pvPortMalloc in the ARMv8-M secure context ports. Reported by Jordan Mecom (Block, Inc.)
|
AniruddhaKanhere
approved these changes
Apr 16, 2026
kstribrnAmzn
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Validate that ulSecureStackSize + securecontextSTACK_SEAL_SIZE does not overflow before calling pvPortMalloc in the ARMv8-M secure context ports.
Reported by Jordan Mecom (Block, Inc.)
Test Steps
Change is validated on a LPCXpresso55S69 (NXP LPC55S69, Cortex-M33 with TrustZone) board.
Checklist:
Related Issue
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.