tillitis / tkey-libs

TKey device libs
GNU General Public License v2.0
4 stars 2 forks source link

Stack canaries #19

Open mchack-work opened 1 year ago

mchack-work commented 1 year ago

Implement stack canaries to help against buffer overflows. lld gives:

ld.lld: error: undefined symbol: __stack_chk_guard

ld.lld: error: undefined symbol: __stack_chk_fail

which hints at what we need to implement.

cobratbq commented 7 months ago

I was looking into the same functionality recently. embeddedartistry.com provides a comprehensive post on this topic. (Other than this post, I found mostly snippets of information.) Given the lack of much runtime support, it seems that one must call function that performs the init manually, or include it right before call main in libcrt0/crt0.S.

Note that there is one minor consideration: if one includes the init-call in crt0.S, then main is no longer called with unmodified program memory.