Skip to content

Workaround certain anti-malware programs#37

Merged
dscho merged 1 commit into
git-for-windows:mainfrom
chirpnot:main
May 13, 2022
Merged

Workaround certain anti-malware programs#37
dscho merged 1 commit into
git-for-windows:mainfrom
chirpnot:main

Conversation

@chirpnot

@chirpnot chirpnot commented Jan 4, 2022

Copy link
Copy Markdown
Contributor

This might break things, but it turns out several Windows libraries like to be loaded at 0x180000000.

This causes a problem, because msys-2.0.dll loads at 0x180040000 and expects 0x180000000-0x180040000 to be available.
A problem arises when Antiviruses (or other DLL hooking mechanisms) load a dll whose preferred load address is 0x180000000 and fits in size before 0x180010000:

  1. msys-2.0.dll loads and fills 0x180010000-0x180040000 assuming no shared console structure is going to be needed.
  2. Another dll loads and fills 0x180000000-0x18000xxxx
  3. msys-2.0.dll tries to load 0x180000000-0x180010000 but it's not available. It falls back to another address, but down the line something else fails.

This bug triggers when using subshells (e.g.: git clone --recursive).

(I guess msys should be able to work around the address conflict, but the code is failing in some way and I'm having a hard time figuring it out, so...)

This addresses git-for-windows/git#3539

@dscho
dscho force-pushed the main branch 3 times, most recently from 8d105b8 to d3507f2 Compare January 5, 2022 14:40
@dscho

dscho commented Jan 5, 2022

Copy link
Copy Markdown
Member

A couple of comments:

  • Could I ask you to use your real name and email address in your user.name and user.email configuration and then call git commit --amend --reset-author -s, then force-push?
  • How did you come up with 0x210347000?
  • I cherry-picked two fixes to allow the CI build to start.
  • Since the build now succeeds, and since I have no way to reproduce the original issue, could I ask you to test the build artifact?

@chirpnot

Copy link
Copy Markdown
Contributor Author
  • Could I ask you to use your real name and email address in your user.name and user.email configuration and then call git commit --amend --reset-author -s, then force-push?

Will do.

  • How did you come up with 0x210347000?

You mean 0x210040000? Random choice. If you have any scientific-like idea to get a new base address, my ears are wide open.

The only semi-feasible approach imho would be to take a windows install and query all the base addresses of all the exe/dll's and then choose something that's not there, but still...

  • I cherry-picked two fixes to allow the CI build to start.
  • Since the build now succeeds, and since I have no way to reproduce the original issue, could I ask you to test the build artifact?

I confirm it seems to work. I managed to get .\strace.exe .\cmd.exe => .\lsattr.exe to crash in git-for-windows but not in your CI build.

.\strace.exe .\ldd.exe crashes both, but I think it's unrelated. Could you please try it on your machine?

@chirpnot

chirpnot commented Mar 10, 2022

Copy link
Copy Markdown
Contributor Author

Ok, even rebasing msys-2.0.dll in the broken version, strace lsattr still crashes :/ so I guess it's unrelated. Will do some more differential testing.

EDIT: since the CI build doesn't come with many complex programs, I simply dropped msys-2.0.dll from the CI into git-for-windows and cloned a repo with --recursive. No crash. This increases my gut feeling that the strace thing is another problem.

This might break things, but it turns out several Windows libraries like
to be loaded at 0x180000000.

This causes a problem, because `msys-2.0.dll` loads at `0x180040000` and
expects `0x180000000-0x180040000` to be available. A problem arises when
Antiviruses (or other DLL hooking mechanisms) load a DLL whose preferred
load address is `0x180000000` and fits in size before `0x180010000`:

1. `msys-2.0.dll` loads and fills `0x180010000-0x180040000` assuming no
   shared console structure is going to be needed.

2. Another DLL loads and fills `0x180000000-0x18000xxxx`

3. `msys-2.0.dll` tries to load `0x180000000-0x180010000` but it's not
   available. It falls back to another address, but down the line
   something else fails.

This bug triggers when using subshells (e.g.: `git clone --recursive`).

The MSYS2 runtime should be able to work around the address conflict,
but the code is failing in some way or other...

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Mikael Larsson <[email protected]>
@dscho

dscho commented May 10, 2022

Copy link
Copy Markdown
Member

@orgads since you have access to Windows 7, could I trouble you to test this?

@orgads

orgads commented May 10, 2022

Copy link
Copy Markdown
Contributor

Sure, I'll test it tomorrow.

@orgads

orgads commented May 11, 2022

Copy link
Copy Markdown
Contributor

Works for me on Win7. No crash on git clone --recursive (I didn't try to reproduce with the official version).

@dscho dscho changed the title Workaround for #3539 Workaround certain anti-malware programs May 13, 2022
@dscho
dscho merged commit d92c46b into git-for-windows:main May 13, 2022
dscho added a commit to dscho/msys2-runtime that referenced this pull request May 13, 2022
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho

dscho commented May 13, 2022

Copy link
Copy Markdown
Member

Thank you @chirpnot!

dscho added a commit to git-for-windows/build-extra that referenced this pull request May 14, 2022
Many anti-malware products seem to have problems with our MSYS2
runtime, leading to problems running e.g. `git subtree`. We [added a
workaround](git-for-windows/msys2-runtime#37)
that hopefully helps in most of these scenarios.

Signed-off-by: Johannes Schindelin <[email protected]>

@Stmgme Stmgme left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K

dscho added a commit to dscho/msys2-runtime that referenced this pull request Sep 5, 2022
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request May 12, 2023
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jun 16, 2023
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jun 19, 2023
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Sep 6, 2023
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Nov 29, 2023
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Aug 30, 2024
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Sep 5, 2024
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Sep 18, 2024
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Dec 24, 2024
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jan 26, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jan 26, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jan 26, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jan 27, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jan 28, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jan 30, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Mar 21, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Mar 21, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Apr 9, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Apr 9, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request May 26, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jun 5, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jul 15, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this pull request Oct 10, 2025
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Jan 15, 2026
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/msys2-runtime that referenced this pull request Mar 2, 2026
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this pull request Apr 25, 2026
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this pull request Jul 14, 2026
Workaround certain anti-malware programs

Signed-off-by: Johannes Schindelin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants