Skip to content

Commit 7e03bd3

Browse files
zelenskiCS107E BOT
authored andcommitted
edits to A6 writeup wip
commit 86753a58d6f20e4d2b2e0c88901ed461f3c96150 Author: Julie Zelenski <[email protected]> Date: Sun Feb 16 18:17:29 2025 -0800 edits to A6 writeup wip
1 parent 50f0621 commit 7e03bd3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

assignments/assign4/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ The gcc compiler has a feature called "StackGuard" that helps with detecting buf
150150

151151
Here is a CompilerExplorer link <https://gcc.godbolt.org/z/MqEMMf6cc> that compares the assembly for a regular compile to the assembly generated when StackGuard is enabled. Carefully trace the assembly and sketch a stack diagram to see how StackGuard works. Notice that the canary is applied to a function that declares a stack buffer, other functions do not require protection.
152152

153-
StackGuard relies on two global symbols, `__stack_chk_guard` (a data symbol containing the value to use for canary) and `__stack_chk_fail` (a function called when overflow is detected). These symbols are provided in the standard library, but given we run bare-metal, we must write them for ourselves. Set the canary value to a value of your choice, and implement the fail function to report where the stack smashing was detected and call `mango_abort` to terminate the program.
153+
StackGuard relies on two global symbols, `__stack_chk_guard` (a data symbol containing the value to use for canary) and `__stack_chk_fail` (a function called when overflow is detected). These symbols are provided in the standard library, but given we run bare-metal, we must write them for ourselves. Set the canary value to a value of your choice, and implement the fail function to report where the stack smashing was detected and call `mango_abort()` to terminate the program.
154154

155-
If the canary has been damaged, everything upward in the stack is potentially compromised. The only part of the stack that you know to be valid is the tippy-top, where the stack frame for `__stack_chk_fail` itself is. In this dicey context, you should not attempt a call to the full version of `gather_backtrace`, so instead you must write code to very carefully extract just the single `ra` and work from there to identify which function called `__stack_chk_fail` so you can report where the stack smashing happened.
155+
If the canary has been damaged, everything upward in the stack is potentially compromised. The only part of the stack that you know to be valid is the tippy-top, where the stack frame for `__stack_chk_fail` itself is. In this dicey context, you should not attempt a call to the full version of `gather_backtrace`, so instead you must write code to very carefully extract just the single `ra` and work from there to identify which function called `__stack_chk_fail` so you can report where the stack smashing happened. We ask that your message use the exact format and wording we show here:
156156

157157
```console
158158
*** Stack smashing detected at end of function bad_guy() ***

header.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pre {
3636
}
3737
</style>
3838

39-
{% assign header_names = "assert,backtrace,console,de,fb,font,gl,gpio,gpio_extra,gpio_interrupt,hdmi,hstimer,interrupts,keyboard,malloc,mango,mouse,printf,ps2,ps2_keys,rand,ringbuffer,shell,shell_commands,strings,symtab,timer,uart" | split: ',' %}
39+
{% assign header_names = "assert,backtrace,console,de,fb,font,gl,gpio,gpio_extra,gpio_interrupt,hdmi,hstimer,interrupts,keyboard,malloc,mango,memmap,mouse,printf,ps2,ps2_keys,rand,ringbuffer,shell,shell_commands,strings,symtab,timer,uart" | split: ',' %}
4040

4141
<div class="row flex-row">
4242
<div class="nav nav-pills flex-column sidenav">

0 commit comments

Comments
 (0)