Fix alignment issues in QCBOR lib
Closed, ResolvedPublic

Description

The following QCBOR test cases were disabled because a memory unalignment exception can happen with ARMCLANG in Release build (-03 optimisation):

  • AllocAllStringsTest
  • IndefiniteLengthArrayMapTest
  • MemPoolTest
  • IndefiniteLengthStringTest

The issue only affect the QCBOR decoder when infinitive length of arrays or string is decode. This scenario is very unlikely in an embedded environment.

The issue happens in QCBORDecode_SetMemPool() when code tries to store data with STM instruction to not aligned address.

tamasban created this task.Feb 14 2019, 5:09 PM
tamasban triaged this task as Normal priority.

To be most clear, this issue only arrises if QCBORDecode_SetMemPool() is called by the user of the CBOR decoder to configure the internal string allocator.

There is no issue if any of these are true:

  • QCBORDecode_SetUpAllocator() is used to configure an external string allocator
  • No indefinite length strings are encountered
  • The CPU supports unaligned access

The attestation use case only uses decoding during test, doesn't involve indefinite length strings and doesn't call QCBORDecode_SetMemPool() so it is not affected.

I believe I have a solution, but it involved a lot of changes and needs to be tested thoroughly before it is promoted.

tamasban closed this task as Resolved.Apr 17 2019, 11:42 AM