It looks like all we have to do is initialize __stack_chk_guard to a random number and provide a __stack_chk_fail function which exits the program. Linux provides 16 random bytes to every process via the auxiliary vector and lone already uses those to initialize its hash functions. It should be possible to use those random bytes to initialize the stack canary as well.
Possible implementation alternative: trapping stack smashing protector which eliminates the need to implement __stack_chk_fail. I've also requested the ability to rename these symbols.
GCC stack smashing protection references:
When stack smashing protection is turned on, the compiler generates some fairly simple code:
It looks like all we have to do is initialize
__stack_chk_guard
to a random number and provide a__stack_chk_fail
function which exits the program. Linux provides 16 random bytes to every process via the auxiliary vector and lone already uses those to initialize its hash functions. It should be possible to use those random bytes to initialize the stack canary as well.Originally posted by @matheusmoreira in https://github.com/lone-lang/lone/issues/3#issuecomment-1916786898