- Notifications
You must be signed in to change notification settings - Fork13.3k
Nice stack smashing postmortem message#8670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Wire everything that relies on stack smashing detection to call`__stack_chk_fail()` (aka what libssp / ssp / stack-protector uses)Expose it in our debugging headerRename overflow -> smashing, as these are different things we are tryingto detect (meaning, that we check for things writing there, not somekind of `alloca` issue or the way `-fstack-check` would have worked)ref.esp8266#8666`-fstack-protector` continues to work as it always didCONT replaces `abort()`, also moves its check to the loop wrapper toavoid dumping otherwise useless SYS context memoryStackThunk replaces a similar `abort()` call
CollaboratorAuthor
mcspr commentedSep 13, 2022
btw, something to reproduce failures #include<Arduino.h>#include<StackThunk.h>#include<umm_malloc/umm_malloc.h>#include<cont.h>#include<user_interface.h>#include<array>// reproduce crash for all three methods, in sequenceconstexpruintptr_t RtcMem {0x60001200 +128 };auto* count =reinterpret_cast<volatileuint32_t*>(RtcMem);extern"C" rst_info resetInfo;// there is only a single thunk in the appextern"C"voidthunk_failme();extern"C"voidfailme() {printf("will ravage %p\n", stack_thunk_ptr); *stack_thunk_ptr =0xfafafafa;}make_stack_thunk(failme)// needs -fstack-protector to workvoid ssp_failme() __attribute__((stack_protect));voidssp_failme() {char buf[4];strcpy(buf,"ABCDE");puts(buf);}voidsetup() { Serial.begin(115200);switch (resetInfo.reason) {case REASON_DEFAULT_RST:case REASON_EXT_SYS_RST: *count =0;break; }}voidloop() {constauto last = *count; *count = ((last +1) %3);puts("");printf("%u - wait for it...\n", last);delay(3000);switch (last) {case0: g_pcont->stack_guard1 =0xfafafafa; g_pcont->stack_guard2 =0xfafafafa;break;case1:stack_thunk_add_ref();thunk_failme();break;case2:ssp_failme();break; }} |
hasenradball pushed a commit to hasenradball/Arduino that referenced this pull requestNov 18, 2024
Wire everything that relies on stack smashing detection to call`__stack_chk_fail()` (aka what libssp / ssp / stack-protector uses)Expose it in our debugging headerRename overflow -> smashing, as these are different things we are tryingto detect (meaning, that we check for things writing there, not somekind of `alloca` issue or the way `-fstack-check` would have worked)ref.esp8266#8666`-fstack-protector` continues to work as it always didCONT replaces `abort()`, also moves its check to the loop wrapper toavoid dumping otherwise useless SYS context memoryStackThunk replaces a similar `abort()` call
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wire everything that relies on stack smashing detection to call
__stack_chk_fail()(aka what libssp / ssp / stack-protector uses) Expose it in our debugging headerRename overflow -> smashing, as these are different things we are trying to detect (meaning, that we check for things writing there, not some kind of
allocaissue or the way-fstack-checkwould have worked) ref.#8666-fstack-protectorcontinues to work as it always did CONT replacesabort(), also moves its check to the loop wrapper to avoid dumping otherwise useless SYS context memory StackThunk replaces a similarabort()call