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

Rsa related On Target Tests crash with stack overflow #2194

Closed
RonEld opened this issue Nov 14, 2018 · 12 comments
Closed

Rsa related On Target Tests crash with stack overflow #2194

RonEld opened this issue Nov 14, 2018 · 12 comments
Labels
bug component-crypto Crypto primitives and low-level interfaces

Comments

@RonEld
Copy link
Contributor

RonEld commented Nov 14, 2018

Description

  • Type: Bug
  • Priority: Major
    3 generated On Target tests related to rsa crash with Stack Overflow
    Tested on NRF52840_DK

Bug

OS
Mbed OS

mbed TLS build:
Version: 2.13.0

Expected behavior
Tests to run without crashing

Actual behavior
features-mbedtls-tests-mbedtls-test_suite_pk, features-mbedtls-tests-mbedtls-test_suite_pkcs1_v21 and features-mbedtls-tests-mbedtls-test_suite_rsa crash with stack overflow

Steps to reproduce
generate the On target tests with RSA enabled, and run On Target( Tested on NRF52840_DK, reproduces on K64F If I Remember Correct)

@RonEld RonEld added bug tracking component-crypto Crypto primitives and low-level interfaces labels Nov 14, 2018
@ciarmcom
Copy link

ARM Internal Ref: IOTSSL-2629

@RonEld RonEld self-assigned this Nov 21, 2018
@RonEld
Copy link
Contributor Author

RonEld commented Nov 22, 2018

The failures are consisted of 3 issues:

  1. The tests themselves consume too uch stack
  2. When MBEDTLS_MPI_MAX_SIZE is the default 1024, it consumes too much stack
  3. The tests are too long, and the overall timeout of 180 seconds expire

@RonEld
Copy link
Contributor Author

RonEld commented Nov 22, 2018

Notes to pass the tests (on K64F):

  1. features-mbedtls-tests-mbedtls-test_suite_pk - reduce stack usage in the tests. After building with MBEDTLS_MPI_MAX_SIZE=512, tests finish successfully after 58.71 seconds
  2. features-mbedtls-tests-mbedtls-test_suite_pkcs1_v21 - reduce the stack usage in the tests. After building with MBEDTLS_MPI_MAX_SIZE=768 and MBEDTLS_SHA1_C defined, tests finished successfully after 581.78 seconds. Without MBEDTLS_SHA1_C defined ( default in Mbed OS), all tests skipped, and suite finishes successfully after 260.70 seconds
  3. features-mbedtls-tests-mbedtls-test_suite_rsa -- reduce the stack usage in the tests. After building with MBEDTLS_MPI_MAX_SIZE=768 and MBEDTLS_GENPRIME defined, test finished after 528.74 seconds, only with one failure, in test "RSA Check Public key Object identifier database #6 (N exactly 8192 bits)" which is reasonable considering the MPI Max size. Without MBEDTLS_GENPRIM ( default in Mbed OS), all tests skipped, and suite finishes successfully after 202.92 seconds.

@RonEld
Copy link
Contributor Author

RonEld commented Nov 22, 2018

Open question: Should the timout be increased to a value that should fit the non default configuration (e.g. MBEDTLS_SHA1_C and MBEDTLS_GENPRIME), or should we adapt only to the default configuration, and increase to 300 seconds?

@Patater
Copy link
Contributor

Patater commented Nov 23, 2018

Let's increase the timeout. It will let us run on more targets, but shouldn't slow down the quicker ones.

@RonEld
Copy link
Contributor Author

RonEld commented Nov 25, 2018

@Patater
My question was whether we wan't to increase the timeout to 300 for example, where the default Mbed TLS configuration is set ( without MBEDTLS_SHA1_C and MBEDTLS_GENPRIME ), or should we increase to 600, to fit these tests as well?

Note that the module that consumes the most time, as I saw, is the greentea test infrastructure, trying to serialize and deserialize the long test data in these tests, so I don't think this is platform dependent( perhaps a bit dependent on the MCU \ networking etc.. )

@RonEld RonEld mentioned this issue Nov 25, 2018
4 tasks
@RonEld
Copy link
Contributor Author

RonEld commented Nov 25, 2018

With PR #2230 and setting MBEDTLS_MPI_MAX_SIZE to 512, all of the tests succeed except:
"RSA Check Public key #6 (N exactly 8192 bits)" test, which is reasonable, considering the max mpi size

Need to add a condition dependency in the test infrastructure

@RonEld
Copy link
Contributor Author

RonEld commented Nov 25, 2018

features-mbedtls-tests-mbedtls-test_suite_pkcs1_v15 also crashes when MBEDTLS_SHA1_C and MBEDTLS_GENPRIME are defined

@RonEld
Copy link
Contributor Author

RonEld commented Nov 29, 2018

Need to add a condition dependency in the test infrastructure

This has been addressed in #2231

@RonEld
Copy link
Contributor Author

RonEld commented Dec 2, 2018

Setting the default size of MBEDTLS_MPI_MAX_SIZE to 512 in Mbed OS has been raised in
ARMmbed/mbed-os#8936

@RonEld
Copy link
Contributor Author

RonEld commented Dec 2, 2018

@tom-cosgrove-arm
Copy link
Contributor

Closing this issue as on-target testing was removed from Mbed TLS in PR #5116 (#4944 for 2.28 LTS), following the announcement in issue #4912 in Sep 2021.

A separate issue (#5595) has been raised as a placeholder, in case we want to come back to it at some point in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-crypto Crypto primitives and low-level interfaces
Projects
None yet
Development

No branches or pull requests

4 participants