简体   繁体   English

如何通过分段或分页防止缓冲区溢出?

[英]How to prevent Buffer overflow with segmentation or paging?

How do you make use of segmentation and paging to prevent buffer overflow? 您如何利用分段和分页来防止缓冲区溢出? One guess might be - because segmentation only gives a portion of memory to each process and if the process tried to access an address outside its segment then a segfault will occur. 一个猜测可能是-因为分段只会为每个进程提供一部分内存,并且如果该进程试图访问其分段之外的地址,则会发生段错误。 Please tell me if that is correct or not. 请告诉我这是否正确。 Thank you! 谢谢!

Segmentation / paging will not prevent your code from attempting to access memory outside of its boundaries. 分段/分页不会阻止您的代码尝试访问其边界之外的内存。 That is the definition of a buffer overflow, and no sort of memory protections will attempt broken code from attempting to do things it is not allowed to do. 这就是缓冲区溢出的定义,并且没有任何内存保护措施可以尝试尝试执行不允许执行的操作来破坏代码。

What segmentation or paging can do, is prevent your code from successfully accessing memory it doesn't own. 分段或分页可以做的是阻止您的代码成功访问它不拥有的内存。 The only option an operating system really has is to kill a process that the hardware has detected attempting to do something "bad". 操作系统真正具有的唯一选择是杀死硬件检测​​到的尝试执行“不良”操作的进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM