Description
The Git for Windows binaries don't work with ASLR because of the way cygwin/Mingw/MSYS/whatever implements fork
. This is unfortunate, but ain't gonna change anytime soon (as per #1196 etc.).
However, running with Mandatory ASLR enabled may be useful or desired as part of computer hardening.
A (sad) workaround is to add exceptions to the system policy and exempt the Git binaries from ASLR.
Doing that through the GUI is crazy as there are 444 such EXEs. The PowerShell Set-ProcessMitigation
cmdlet doesn't support using full paths; it would exempt any process with a given name. The two options left are preparing an XML of an undocumented but easily understandable schema and importing it using Set-ProcessMitigation -PolicyFilePath
or editing the Registry manually.
The following is a PowerShell script that directly manipulates the Registry and adds exceptions for all the EXE files inside the Git directory except the 3 found at the root: https://gitlab.com/conio.h/GfW_ASLR_Exceptions
It expects a path to the Git directory (e.g. "C:\Program Files\Git") and looks for the git install directory in the Registry if no path is provided. The path parameter can be used for "portable git" installs.
There's virtually no error checking there. I have no idea what happens if you gives a bad path, for example. What I can say is that "it works on my computer" (RS3 x64, if anybody cares).