https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65674
Bug ID: 65674 Summary: stack smashing protector must be controllable per-function Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: stsp at users dot sourceforge.net Hello. 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.