This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
Approximated stack overflow detection via stack canaries #31
Labels
type: enhancement
Enhancement or feature request
Projects
While it is possible to link an embedded app in a way that will detect stack overflows immediately and (mostly) reliably, few people actually do this as it requires using a linker wrapper to link the app twice. cortex-m-rt also doesn't do it by default at the moment.
However, we can still do our best to help out when no built-in stack overflow protection is used: After uploading the program, but before starting it, we can fill the space in RAM right after the data used by ELF sections with a unique pattern. Then, after the program exits (or even while it still runs), we scan the filled area and look for bytes that were changed from our pattern. If we find any changed bytes, there is a high probability that the program has used too much stack and overwrote its own data sections.
There are a few things to keep in mind here:
The text was updated successfully, but these errors were encountered: