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 was merged in pull request #2955.
This commit is contained in:
+127
-127
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 = "";
|
||||
|
||||
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_cb_tcpip_init
|
||||
-Wl,--wrap=cyw43_cb_tcpip_deinit
|
||||
|
||||
-Wl,--wrap=__stack_chk_fail
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ def BuildStackProtect(name):
|
||||
print("%s.menu.stackprotect.Disabled=Disabled" % (name))
|
||||
print("%s.menu.stackprotect.Disabled.build.flags.stackprotect=" % (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):
|
||||
print("%s.menu.exceptions.Disabled=Disabled" % (name))
|
||||
|
||||
Reference in New Issue
Block a user