I have a few questions about Stack Guard and SSP protections. First question is about Stack Guard and its three types of canaries, if I am correctly - terminator, random and random XOR.
I'd like to know, how to disabled Stack Guard on x86 Linux system? Somewhere I read, it's possible with this command, while compiling with gcc
-disable-stackguard-randomization
, it's same like with this command for enable-enable-stackguard-randomization
, both doesn't work. If needed, my gcc version is 4.8.2.Next question about Stack guard, when I will able to enable/disable it, how can I set, which type of canaries I want to use? What I read, terminator canaries are used by default, for random I have to compiled with
-enable-stackguard-randomization
, but how about random XOR? (Or with null 0x00000000)Now about SSP(ProPolice), I know, for random canary I have to compiled with
fstack-protector-all
, but how about terminator, is it same as in Stack Guard, by default?Last one, where I can find random canary in memory? For example, I have this scenario - compiled C program, like
gcc -g example.c -o example -fstack-protector-all
, so with random canaries. Let's say, I'm able to get address of canary, after every execution. So I expectCanary = 0x1ae3f900
.From a different papers, I get some info, that canary is located in .bss segment. So I get address of .bss segment using readelf:
readelf -a ./example | grep bss
. It's 080456c9. In gdb I set some breakpoints, to get address of canary, but when I check .bss addressx/20x 0x080456c9
, all I see are only 0x00000000 addresses, but canary is nowhere. Plus, I checked__stack_chk_fail
's if it isn't there, but with same result, I can't see it there. I get address of stack_chk_fail from PLT/GOT.
gcc -fno-stack-protector
orgcc -fstack-protector=strong
. When and how to use GCC's stack protection feature? and gcc.gnu.org/onlinedocs/gcc/…. See also Why does this memory address %fs:0x28 ( fs[0x28] ) have a random value? which points out that normal stack-protector randomizes the stack cookie. – Matteo-fstack-protector-strong
, not=
. – Matteo