RĂ©mi Bernon rbernon@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 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.