http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61063

            Bug ID: 61063
           Summary: Improve -fstack-protector-all
           Product: gcc
           Version: 4.3.4
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Ulrich.Windl at rz dot uni-regensburg.de

I had made a programming error that I could not find with
-fstack-protector-all, but I think it should have helped:
My bug was related to pthread_join() when the thread return parameter received
a pointer to an integer (as the thread actually returns an integer).
Unfortunately on x86_64 sizeof(int) != sizeof(void *), so my program overwrote
the stack.
Interestingly with -O0 things seemed to work, but with -O2 things went grazy.
When the program eventually caused a SIGSEGV the stack was completely unusable
(program crashed on return).

AFAIK, stack-protect pads some magic bytes around on the stack that are checked
before return. As it didn't help much diagnosing my problem, I'd like to
suggest the following enhancements:

1) Don't add some magic bytes at one place on the stack, but add magic bytes
around _every_ variable on the stack.

2) Don't just call the integrity test for the magic bytes before return, but
every time a variable on the stack is modified.

I know it will hit performance hard, but I wasted several hours until I found
why my code broke.

Reply via email to