-
Notifications
You must be signed in to change notification settings - Fork 54
Fix ret2spec demo so it doesn't segfault without optimizations #26
Comments
It works also with -O1 or even just with -fomit-frame-pointer. |
The issue is that -O0 by default uses rbp (or ebp) for addressing the stack variables instead of rsp (or esp). Ebp is pushed on the stack on prologue of each function and restored in its epilogue, because it's a callee-saved register by the calling-convention. By unrolling the stack to create the RSB mismatch I'm destroying its value misdirecting all following stack accesses. It is possible to detect it just creating two functions that do nothing and observing whether the value of rbp changed across them. |
It does work with |
I'll look at this eventually. That's unexpected. |
There are at least two problems:
|
Current behavior if the example is compiled at
-O0
:I think it's okay if the example doesn't work below
-O2
, but we should improve it so it at least doesn't crash.The text was updated successfully, but these errors were encountered: