V2 [PATCH] x86/CET: Add a setcontext test for CET
H.J. Lu
hjl.tools@gmail.com
Wed Jul 25 15:02:00 GMT 2018
On Wed, Jul 25, 2018 at 6:29 AM, Carlos O'Donell <carlos@redhat.com> wrote:
> On 07/25/2018 08:22 AM, H.J. Lu wrote:
>> Verify that setcontext works with gaps above and below the newly
>> allocated shadow stack.
>>
>> OK for master?
>>
>> H.J.
>> ---
>> * sysdeps/x86/Makefile (tests): Add tst-cet-setcontext-1 if
>> CET is enabled.
>> (CFLAGS-tst-cet-setcontext-1.c): Add -mshstk.
>> * sysdeps/x86/tst-cet-setcontext-1.c: New file.
>
> OK for 2.28 only if you add a paragraph about exactly how the shadow
> stacks are being laid out by the calls and why unmapping ctx3 and ctx4 works
> to leave ctx1 with gap above and below.
>
Here is the updated patch with a comment:
/* NB: When shadow stack is enabled, makecontext calls arch_prctl
with ARCH_CET_ALLOC_SHSTK to allocate a new shadow stack which
can be unmapped. The base address and size of the new shadow
stack are returned in __ssp[1] and __ssp[2]. makecontext is
called for CTX1, CTX3 and CTX4. But only CTX1 is used. New
shadow stacks are allocated in the order of CTX3, CTX1, CTX4.
It is very likely that CTX1's shadow stack is placed between
CTX3 and CTX4. We munmap CTX3's and CTX4's shadow stacks to
create gaps above and below CTX1's shadow stack. We check that
setcontext CTX1 works correctly in this case. */
It is also moved to sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c since
it is Linux/x86 specific.
OK for master?
Thanks.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-CET-Add-a-setcontext-test-for-CET.patch
Type: text/x-patch
Size: 5160 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180725/230470f5/attachment.bin>
More information about the Libc-alpha
mailing list