Skip to content

Use heap allocation + valgrind in backend unit test #1364

@hanno-becker

Description

@hanno-becker

The backend unit tests would currently not identify buffer overflows in the assembly. For this, we should switch to valgrind and allocate buffers from the heap rather than the stack.

Acceptance criteria:

  • All buffers in the backend unit tests are allocated from the heap by default, to the exact size required.
  • In CI, the backend unit tests are run using valgrind
  • Manually confirm that a deliberately introduced buffer overwrite in the backend assembly would be caught by the unit tests.

This can piggy-back on the customization of MLK_ALLOC/MLK_FREE that was introduced in #1389. Specifically, one can consider simply building test_unit.c with the custom heap allocation config, and change the allocation in test_unit.c to use MLK_ALLOC/MLK_FREE as in the main source files mlkem/src/{indcpa.c/kem.c}.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions