[PATCH] x86: Use pad in pthread_unwind_buf to preserve shadow stack register

H.J. Lu hjl.tools@gmail.com
Fri Mar 30 17:41:00 GMT 2018


On Thu, Mar 29, 2018 at 1:20 PM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * H. J. Lu:
>
>> On Thu, Mar 29, 2018 at 1:15 PM, Florian Weimer <fw@deneb.enyo.de> wrote:
>>> * H. J. Lu:
>>>
>>>> You need to make a choice.  You either don't introduce a new symbol
>>>> version or don't save shadow stack for thread cancellation.  You
>>>> can't have both.
>>>
>>> I don't understand.  We have room to save the shadow stack pointer in
>>> the existing struct.
>>
>> No, we don't have room in struct pthread_unwind_buf:
>>
>> Note: There is an unused pointer space in pthread_unwind_buf_data.  But
>> it isn't suitable for saving and restoring shadow stack register since
>> x32 is a 64-bit process with 32-bit software pointer and kernel may
>> place x32 shadow stack above 4GB.  We need to save and restore 64-bit
>> shadow stack register for x32.
>
> We have for void * fields.  They are subsequently overwritten by
> __pthread_register_cancel.  But __sigsetjmp can write to them first
> without causing any harm.  We just need a private __longjmp_cancel
> that doesn't restore the shadow stack pointer.

Here is the patch which does that.   Any comments?

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-Use-pad-in-pthread_unwind_buf-to-preserve-shadow.patch
Type: text/x-patch
Size: 11254 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180330/a7f46c4b/attachment.bin>


More information about the Libc-alpha mailing list