====== NX Bit ====== The memory of a process is divided into different segments. Roughly speaking, memory regions are distinguished by whether they contain data or executable code. Memory pages which are intended to store data are labeled with the No-eXecute (NX) bit. In case an application tries to execute code located in such a page, an error is raised. Primitive buffer overflows try to execute code on the stack. Due to the fact that the NX bit is set for the memory pages containing the stack, these attacks are prevented. However, it does not defend against [[..exploitation:rop|ROP attacks]] reusing existing code((T. Saito, R. Watanabe, S. Kondo, S. Sugawara and M. Yokoyama, "A Survey of Prevention/Mitigation against Memory Corruption Attacks," 2016 19th International Conference on Network-Based Information Systems (NBiS), Ostrava, 2016, pp. 500-505.)). Note that once an attacker is able to execute code via ROP, the ''mprotect()''(([[http://man7.org/linux/man-pages/man2/mprotect.2.html|mprotect(2) - Linux manual page]])) function can be used to disable the protection of arbitrary memory regions(([[https://www.xorlab.com/blog/2014/05/03/bypassing-non-executable-memory/|Bypassing non-executable memory, ASLR and stack canaries on x86-64 Linux]])). \\ ----
[[.pie|← Back to Position-independent Executable (PIE)]] [[..start|Overview]] [[.cfi|Continue with Control-flow Integrity (CFI) →]]