This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix tst-setcontext9 for optimized small stacks.
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 18 Sep 2018 07:56:33 -0700
- Subject: Re: [PATCH] Fix tst-setcontext9 for optimized small stacks.
- References: <aa47144d-ae4f-319a-7fbd-75b3208dc5a3@redhat.com>
On Tue, Sep 18, 2018 at 7:30 AM, Carlos O'Donell <carlos@redhat.com> wrote:
> HJ,
>
> Can I get a Reviewed-by from you for this? It looks like I'm keeping
> the relative structure of the original test, but I'm not sure what
> your intent was here with respect to CET testing. I'm seeing crashes
> in this test on i686 testing as described in the commit message.
>
> ~~~
> If the compiler reduces the stack usage in function f1 before calling
> into function f2, then when we swapcontext back to f1 and continue
> execution we may overwrite registers that were spilled to the stack
> while f2 was executing. Later when we return to f2 the corrupt
> registers will be reloaded from the stack and the test will crash. This
> was most commonly observed on i686 with __x86.get_pc_thunk.dx and
> needing to save and restore $edx. Overall i686 has few registers and
> the spilling to the stack is bound to happen, therefore the solution to
> making this test robust is to split function f1 into two parts f1a and
> f1b, and allocate f1b it's own stack such that subsequent execution does
> not overwrite the stack in use by function f2.
>
> Tested on i686 and x86_64.
>
> Signed-off-by: Carlos O'Donell <carlos@redhat.com>
>
OK.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
--
H.J.