NX 标志如何工作?
您能否解释一下 NX 标志是什么以及它是如何工作的(请是技术性的)?
Could you please explain what the NX flag is and how it works (please be technical)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您能否解释一下 NX 标志是什么以及它是如何工作的(请是技术性的)?
Could you please explain what the NX flag is and how it works (please be technical)?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
它在虚拟内存系统和 TLB(CPU 用于解析虚拟内存映射的结构)中标记不可执行的内存页。如果要从该页执行任何程序代码,CPU 将出错并将控制权转移给操作系统进行错误处理。
程序通常将二进制代码和静态数据存储在只读内存部分中,如果它们尝试在那里写入,CPU 将出现故障,然后操作系统通常会终止应用程序(这称为分段错误或访问冲突) 。
出于安全原因,程序的读/写数据存储器通常默认受到 NX 保护。这可以防止攻击者向某些应用程序提供其恶意代码作为数据,使应用程序将其写入其数据区域,然后以某种方式执行该代码,通常是通过应用程序中的缓冲区溢出/下溢漏洞,覆盖函数的返回地址与数据区域中恶意代码的位置在堆栈中。
一些合法应用程序(尤其是高性能模拟器和 JIT 编译器)也需要执行其数据,因为它们在运行时编译代码,但它们专门分配内存,但没有为此设置 NX 标志。
It marks a memory page non-executable in the virtual memory system and in the TLB (a structure used by the CPU for resolving virtual memory mappings). If any program code is going to be executed from such page, the CPU will fault and transfer control to the operating system for error handling.
Programs normally have their binary code and static data in a read-only memory section and if they ever try to write there, the CPU will fault and then the operating-system normally kills the application (this is known as segmentation fault or access violation).
For security reasons, the read/write data memory of a program is usually NX-protected by default. This prevents an attacker from supplying some application his malicious code as data, making the application write that to its data area and then having that code executed somehow, usually by a buffer overflow/underflow vulnerability in the application, overwriting the return address of a function in stack with the location of the malicious code in the data area.
Some legitimate applications (most notably high-performance emulators and JIT compilers) also need to execute their data, as they compile the code at runtime, but they specifically allocate memory with no NX flag set for that.
来自维基百科
From Wikipedia
看看维基百科上找到的使用 NX 位的“DEP”。至于提供技术答案,抱歉,我对此了解不够,但引用一下:
另请参阅此处有关 DEP 的 MSDN 知识库。有一个非常详细的解释这里 这是如何工作的。
希望这有帮助,
此致,
汤姆.
Have a look at this 'DEP' found on wikipedia which uses the NX bit. As for supplying the technical answer, sorry, I do not know enough about this but to quote:
See also here from the MSDN's knowledge base about DEP. There is a very detailed explanation here on how this works.
Hope this helps,
Best regards,
Tom.