fix(relinker): keep Windows startup stacks below the guest arena #679
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/679"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-05T14:57:18Z.
What
The relinked Windows executable is marked
HIGH_ENTROPY_VA(DllCharacteristics 0x160), so Windows places the main thread's stack, TEB, PEB and the loader threads' stacks anywhere in the first TiB before libc reserves the guest arena from 0x2_0000_0000. Nearly half the time they land inside it and stay as holes; a fixed guest mapping over one throwsfixed guest mapping overlaps a guest arena range.WindowsPeWriternow writes 0x140 (DYNAMIC_BASE,NX_COMPAT) for relocatable images; 0x100 without relocations is unchanged. The flag only lets ASLR use the whole 64-bit space (PE format, /HIGHENTROPYVA), and the process'sEnableHighEntropyASLR policy follows it.VirtualAllocwithout an address keep only the 8-bit bottom-up randomization instead of up to a TiB, starting near the bottom of the address space. The executable and the DLLs are still relocated into the 0x7ff… image range with either flag.Tested
-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)windows_address_space: relinks theoptional_pltfixture with an entry returningrsp >> 32, checks DllCharacteristics 0x140 and, on Windows, runs it 8 times expecting the stack below 0x2_0000_0000. It fails onmain(0x160). In two series of 200 runs onmain, 195 put the stack in 0x2_0000_0000-0xFC_0000_0000 (81 and 95 below main's arena end 0x72_0000_0000); none do with this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)