Panic on stack protector crash instead of exit (#2955)
Newlib has a stack protector fail handler which write(2)s a message to STDERR which doesn't work here. Override with a call to panic(). Tell GCC to protect all functions for stack protection instead of ones that it heuristically decides need protection. Slower but safer, and only when stack protection is enabled.
This commit is contained in:
parent
de7f1a7e83
commit
d5e844b2bd
4 changed files with 137 additions and 128 deletions
254
boards.txt
254
boards.txt
File diff suppressed because it is too large
Load diff
|
|
@ -244,3 +244,10 @@ void hexdump(const void* mem, uint32_t len, uint8_t cols) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const String emptyString = "";
|
const String emptyString = "";
|
||||||
|
|
||||||
|
extern "C" void __attribute__((__noreturn__)) __wrap___stack_chk_fail() {
|
||||||
|
while (true) {
|
||||||
|
panic("*** stack smashing detected ***: terminated\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,3 +67,5 @@
|
||||||
-Wl,--wrap=cyw43_tcpip_link_status
|
-Wl,--wrap=cyw43_tcpip_link_status
|
||||||
-Wl,--wrap=cyw43_cb_tcpip_init
|
-Wl,--wrap=cyw43_cb_tcpip_init
|
||||||
-Wl,--wrap=cyw43_cb_tcpip_deinit
|
-Wl,--wrap=cyw43_cb_tcpip_deinit
|
||||||
|
|
||||||
|
-Wl,--wrap=__stack_chk_fail
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ def BuildStackProtect(name):
|
||||||
print("%s.menu.stackprotect.Disabled=Disabled" % (name))
|
print("%s.menu.stackprotect.Disabled=Disabled" % (name))
|
||||||
print("%s.menu.stackprotect.Disabled.build.flags.stackprotect=" % (name))
|
print("%s.menu.stackprotect.Disabled.build.flags.stackprotect=" % (name))
|
||||||
print("%s.menu.stackprotect.Enabled=Enabled" % (name))
|
print("%s.menu.stackprotect.Enabled=Enabled" % (name))
|
||||||
print("%s.menu.stackprotect.Enabled.build.flags.stackprotect=-fstack-protector" % (name))
|
print("%s.menu.stackprotect.Enabled.build.flags.stackprotect=-fstack-protector-all" % (name))
|
||||||
|
|
||||||
def BuildExceptions(name):
|
def BuildExceptions(name):
|
||||||
print("%s.menu.exceptions.Disabled=Disabled" % (name))
|
print("%s.menu.exceptions.Disabled=Disabled" % (name))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue