Explanation of MProtect Errno 12 (ENOMEM)

烈酒焚心 提交于 2019-12-01 10:11:09

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)?

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!