[PATCH 2/2] ntdll: Clear the first two stack pages in signal_start_thread.
Rémi Bernon
rbernon at codeweavers.com
Tue Mar 30 15:05:20 CDT 2021
On 3/30/21 8:33 PM, Alexandre Julliard wrote:
> Rémi Bernon <rbernon at codeweavers.com> writes:
>
>>> @@ -1540,10 +1540,8 @@ __ASM_GLOBAL_FUNC( signal_start_thread,
>>> "movq %rcx,%rbx\n\t" /* context */
>>> /* clear the thread stack */
>>> "andq $~0xfff,%rcx\n\t" /* round down to page size */
>>> - "movq %gs:0x30,%rax\n\t"
>>> - "movq 0x10(%rax),%rdi\n\t" /* NtCurrentTeb()->Tib.StackLimit */
>>> - "addq $0x2000,%rdi\n\t"
>>> - "movq %rdi,%rsp\n\t"
>>> + "movq %rcx,%rdi\n\t"
>>> + "subq $0x2000,%rdi\n\t"
>>> "subq %rdi,%rcx\n\t"
>>> "xorl %eax,%eax\n\t"
>>> "shrq $3,%rcx\n\t"
>>
>> Also out of curiosity, what was the reason not to clear the last (last
>> two on x86_64) stack page(s) here?
>
> There's already data there, like the initial context.
I meant on the other side? But I guess the next part answers it, as I
understand we have to keep a bit of space for anything that would need a
stack while we clear the pages.
>
>> I also removed the rsp stores, assuming it wasn't used for rep movs
>> anyway but I'm now thinking that maybe all this was here for the case
>> we get signaled while clearing the pages?
>
> Yes, in general touching the stack below the stack pointer is not a good
> idea.
>
--
Rémi Bernon <rbernon at codeweavers.com>
More information about the wine-devel
mailing list