[Bug target/65674] New: stack smashing protector must be controllable per-function
stsp at users dot sourceforge.net
Sun Apr 5 23:06:00 GMT 2015
Bug ID: 65674
Summary: stack smashing protector must be controllable
Assignee: unassigned at gcc dot gnu.org
Reporter: stsp at users dot sourceforge.net
On x86 (both 32 and 64), linux doesn't set
FS and GS registers to the sane values when
invoking the signal handler. Therefore the
first thing the sig handler should do is to
restore these registers if the program itself
can ever modify them.
Unfortunately gcc uses them in prolog/epilog
for ssp, and so the "stack smashing detected".
I think attribute "no_instrument_function" or
"naked" should do that, but currently they don't,
which is almost a bug, at least "no_instrument_function"
is supported but doesn't give the desired effect.
I can't even think of any reasonable work-around.
For example I could do the small asm wrapper that
restores these regs, but on x86_64 this is not
enough: you need to set their base separately,
via the prctl() syscall. Doing this all from asm
is too nasty, I really think gcc should allow
writing the proper sighandler.
More information about the Gcc-bugs