I\'m writing an iPhone application using Monotouch and recently the app has started crashing stating
Mprotect failed at 0x863a000 (length 8192) with errno 1
Does your app use Generics?
Beware of having virtual methods on types with Generics, for Monotouch, which has to do lots of hacks while pre-jitting and some more magic with trampolines, it can cause some method hijacking, or memory corruption, on my experience, YMMV.
Make all methods non-virtual on Generic classes for safety.
mprotect(2) asks the operating system kernel to change the protection mode for some portion of address space.
mprotect(2)
is often used to make data sections of an address space non-executable, so that buffer overflows, format string vulnerabilities, use after free or freeing unallocated memory errors, or similar attacks cannot return into attacker-supplied data. Also, mprotect(2)
is used to ensure that the program text
space cannot be modified by those same vulnerabilities. (If an attacker can simply overwrite the functions you've supplied, that's no good.)
But mprotect(2)
isn't magic; it cannot prevent against return to libc attacks, or improper use of system(3)
or other code interpreters, etc.
What is the C symbol for the errno
value 12
on the iPhone? Where and why does Monotouch use mprotect(2)
itself? Any chance your software uses mprotect(2)
?