Reducing stack memory consumption #355

Open
opened 2020-01-27 04:58:27 -06:00 by pouyaashraf · 2 comments
pouyaashraf commented 2020-01-27 04:58:27 -06:00 (Migrated from github.com)

Description

When using the mbedtls library on certain embedded platforms, a stack-allocated buffer (buf in mbedtls_rsa_rsassa_pss_verify_ext) provokes a stack overflow. The platform in question is LittleKernel running on ARM, where we unfortunately don't have the option of increasing the stack alotted to the kernel. Changing the buf variable to have static storage duration resolves this, but then the function becomes thread un-safe which is not desirable.

Issue request type

[ ] Question
[x] Enhancement
[ ] Bug
<!-- ************************************** WARNING ************************************** The ciarcom bot parses this header automatically. Any deviation from the template may cause the bot to automatically correct this header or may result in a warning message, requesting updates. Please ensure that nothing follows the Issue request type section, all issue details are within the Description section and no changes are made to the template format (as detailed below). ************************************************************************************* --> ### Description When using the mbedtls library on certain embedded platforms, a stack-allocated buffer (`buf` in `mbedtls_rsa_rsassa_pss_verify_ext`) provokes a stack overflow. The platform in question is LittleKernel running on ARM, where we unfortunately don't have the option of increasing the stack alotted to the kernel. Changing the `buf` variable to have static storage duration resolves this, but then the function becomes thread un-safe which is not desirable. <!-- Required Add detailed description of what you are reporting. Good example: https://os.mbed.com/docs/latest/reference/workflow.html Things to consider sharing: - What target does this relate to? - What toolchain (name + version) are you using? - What tools (name + version - is it mbed-cli, online compiler or IDE) are you using? - What is the SHA of Mbed OS (git log -n1 --oneline)? - Steps to reproduce. (Did you publish code or a test case that exhibits the problem?) --> ### Issue request type <!-- Required Please add only one X to one of the following types. Do not fill multiple types (split the issue otherwise.) Please note this is not a GitHub task list, indenting the boxes or changing the format to add a '.' or '*' in front of them would change the meaning incorrectly. The only changes to be made are to add a description text under the description heading and to add a 'x' to the correct box. --> [ ] Question [x] Enhancement [ ] Bug
pouyaashraf commented 2020-01-27 05:02:30 -06:00 (Migrated from github.com)

To add to this, the amount of memory allocated by buf is 1KiB, and it's done here: https://github.com/ARMmbed/mbed-crypto/blob/development/library/rsa.c#L2165

To add to this, the amount of memory allocated by `buf` is 1KiB, and it's done here: https://github.com/ARMmbed/mbed-crypto/blob/development/library/rsa.c#L2165
ciarmcom commented 2020-01-27 07:26:08 -06:00 (Migrated from github.com)
*Internal Jira reference: https://jira.arm.com/browse/IOTCRYPT-1042*
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-ARMmbed/mbed-crypto#355
No description provided.