Skip to content

SPMATH and WOLFBOOT_SMALL_STACK testing failures? #614

Description

@gojimmypi

This issue is for reference as related to #613 (and may be incorrect)

I've recently added some new tests, and it appears the SP Math concurrent with Small Stack settings may be problematic.

I will disable the tests for now and include this PR as a TODO:

        exclude:
          - math: "SPMATH=1 WOLFBOOT_SMALL_STACK=1"
          - math: "SPMATHALL=1 WOLFBOOT_SMALL_STACK=1"

For reference from a recent workflow:

Annotations
27 errors
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc256, sha384)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc256, sha256)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc256, sha3)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc384, sha3)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc384, sha256)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc384, sha384)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc521, sha256)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc521, sha3)
Process completed with exit code 1.
test-lib (SPMATH=1 WOLFBOOT_SMALL_STACK=1, ecc521, sha384)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc384, sha256)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc384, sha384)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc256, sha3)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc256, sha256)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc256, sha384)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc384, sha3)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc521, sha384)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc521, sha3)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, ecc521, sha256)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa2048, sha256)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa2048, sha3)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa2048, sha384)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa3072, sha256)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa3072, sha384)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa3072, sha3)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa4096, sha3)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa4096, sha384)
Process completed with exit code 1.
test-lib (SPMATHALL=1 WOLFBOOT_SMALL_STACK=1, rsa4096, sha256)
Process completed with exit code 1.

The failure reasons are not very intuitive:

Run # Sample build
  # Sample build
  build_once() {
      # Convert asym and hash to upper case, optionally add additional param
      make -j test-lib SIGN=${ASYM^^} HASH=${HASH^^} ${MATH} "$@"
  }
  
  set -euo pipefail
  
  # Get the reference config
  cp config/examples/library.config .config
  
  # Keytools
  make keytools
  ./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der
  
  # Sign
  echo "Test" > test.bin
  ./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1
  
  # First attempt
  if build_once >build.out 2>build.err; then
    echo "Success on first attempt"
    exit 0
  fi
  
  # If it failed due to the TFM huge stack guard, retry with the flag
  if grep -q 'If this is OK, please compile with WOLFBOOT_HUGE_STACK=1' build.err; then
    echo "Retrying with WOLFBOOT_HUGE_STACK=1 due to TFM stack requirement"
    build_once WOLFBOOT_HUGE_STACK=1
  else
    echo "Build failed for another reason:"
    cat build.err
    exit 1
  fi
  shell: /usr/bin/bash -e {0}
  env:
    shell: bash
    ASYM: ecc256
    HASH: sha384
    MATH: SPMATH=1 WOLFBOOT_SMALL_STACK=1
Building key tools
make[1]: Entering directory '/home/runner/work/wolfBoot/wolfBoot/tools/keytools'
Building signing tool
Building keygen tool
make[1]: Leaving directory '/home/runner/work/wolfBoot/wolfBoot/tools/keytools'
Keystore size: 2608
Keytype: ECC256
Generating key (type: ECC256)
Associated key file:   wolfboot_signing_private_key.der
Partition ids mask:   ffffffff
Key type   :           ECC256
Public key slot:       0
Done.
wolfBoot KeyTools (Compiled C version)
wolfBoot version 2060000
Update type:          Firmware
Input image:          test.bin
Selected cipher:      ECC256
Selected hash  :      SHA384
Private key:           wolfboot_signing_private_key.der
Output  image:        test_v1_signed.bin
Target partition id : 1 
Manifest header size: 256
Calculating SHA384 digest...
Signing the digest...
Sign: 02
Output image(s) successfully created.
Success on first attempt
0s
Run ./test-lib test_v1_signed.bin
Boot partition: 0x562ff0083490 (sz 5, ver 0x1, type 0x201)
Failure -2: Hdr 1, Hash 1, Sig 0
Error: Process completed with exit code 1.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions