Created
September 28, 2018 12:55
-
-
Save BrzVlad/dcee172c24cc532a02d887b96cd4704c to your computer and use it in GitHub Desktop.
mmap/mprotect reversal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c | |
index 6297bacf704..f78807139f0 100644 | |
--- a/mono/mini/mini-exceptions.c | |
+++ b/mono/mini/mini-exceptions.c | |
@@ -2750,12 +2750,10 @@ mono_setup_altstack (MonoJitTlsData *tls) | |
g_assert ((guint8*)&sa >= (guint8*)tls->stack_ovf_guard_base + tls->stack_ovf_guard_size); | |
- if (mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE)) { | |
- /* mprotect can fail for the main thread stack */ | |
- gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED, MONO_MEM_ACCOUNT_EXCEPTIONS); | |
- g_assert (gaddr == tls->stack_ovf_guard_base); | |
+ if (mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE | MONO_MMAP_PRIVATE | MONO_MMAP_ANON | MONO_MMAP_FIXED, MONO_MEM_ACCOUNT_EXCEPTIONS)) | |
tls->stack_ovf_valloced = TRUE; | |
- } | |
+ else if (mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE)) | |
+ g_error ("Couldn't setup stack guard page"); | |
/* Setup an alternate signal stack */ | |
tls->signal_stack = mono_valloc (0, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON, MONO_MEM_ACCOUNT_EXCEPTIONS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment