This is the mail archive of the
mailing list for the GCC project.
Re: RFA: Need to extend x86 psABI to support thread cancellation and alternate signal stack
- From: Florian Weimer <fweimer at redhat dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, GCC Development <gcc at gcc dot gnu dot org>, Carlos O'Donell <carlos at redhat dot com>
- Date: Tue, 27 Mar 2018 17:43:02 +0200
- Subject: Re: RFA: Need to extend x86 psABI to support thread cancellation and alternate signal stack
- References: <CAMe9rOp_ODUck1Oa6cRPKVRkedQ=sq8RrNwPtBQ5RSvyEunemail@example.com> <firstname.lastname@example.org> <CAMe9rOrWO+j5c63H_uay9g4spTMCnGYbEVOMe7kVhJeDMz2gfg@mail.gmail.com>
On 03/27/2018 01:26 PM, H.J. Lu wrote:
2. Since shadow stack is never saved and restored by compiler, unwinder
in libgcc counts how many stack frame it has to unwind and uses INCSSP
to pop shadow stack. This can't unwind the original shadow stack when
the alternate shadow stack is used. _URC_NO_REASON_CANCEL
works only if longjmp will be used to finish stack unwinding, which is
the case for thread cancellation in glibc.
Here are patches for GCC:
They fixed the issue.
The patches are nice and short, but: Do they really fix the issue? They
make cancellation work again, but they do not fix the general unwinding
issue with alternate signal handler stacks AFAICS.
It may be possible to implement this without kernel changes: Patch the
interrupted context to continue unwinding, and then call sigreturn to switch
both stacks at the same time.
We passed almost all 5000+ tests in glibc with shadow stack and indirect
branch tracking enabled. The only remaining failures are thread cancellation
with alternate signal stack and -fasynchronous-unwind-tables. I couldn't
find a way to unwind shadow stack by counting stack frame when exception
happens in alternate signal stack.
I'm not sure how comprehensive these tests are, considering that no one
expected something like shadow stacks (maybe those dual ia64 stacks are
somewhat similar, but I don't know anything about them).