Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FP SmallStack Fix #7980

Merged
merged 1 commit into from
Sep 17, 2024
Merged

FP SmallStack Fix #7980

merged 1 commit into from
Sep 17, 2024

Conversation

ejohnstown
Copy link
Contributor

@ejohnstown ejohnstown commented Sep 17, 2024

Description

The function _fp_exptmod_nct() is using WOLFSSL_NO_MALLOC to guard using stack allocation vs malloc. It's twin function _fp_exptmod_ct() is using WOLFSSL_SMALL_STACK for this. This is causing inappropriate use of malloc() in a small stack environment. The no-malloc case will also be kept so static memory and no-malloc fix still works.

  1. Change the guards for #ifndef WOLFSSL_NO_MALLOC in the function _fp_exptmod_nct() to #if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC).

Testing

Verified the code path is correctly set. Ran the wolfcrypttest in the debugger to confirm allocation and no allocation in the function _fp_exptmod_nct(). Ran the wolfcrypttest in valgrind.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

wolfcrypt/src/tfm.c Outdated Show resolved Hide resolved
The function _fp_exptmod_nct() is using WOLFSSL_NO_MALLOC to guard
using stack allocation vs malloc. It's twin function _fp_exptmod_ct()
is using WOLFSSL_SMALL_STACK for this. This is causing inappropriate use
of malloc() in a small stack environment. The no-malloc case will also
be kept so static memory and no-malloc fix still works.

1. Change the guards for `#ifndef WOLFSSL_NO_MALLOC` in the function
   `_fp_exptmod_nct()` to `#if defined(WOLFSSL_SMALL_STACK) &&
   !defined(WOLFSSL_NO_MALLOC)`.
@ejohnstown ejohnstown assigned wolfSSL-Bot and unassigned ejohnstown Sep 17, 2024
@douzzer douzzer merged commit ef6f156 into wolfSSL:master Sep 17, 2024
135 checks passed
@ejohnstown ejohnstown deleted the small-stack-fp branch September 17, 2024 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants