linux – mmap内存保护的目的是什么PROT_NONE


PROT_NONE Pages may not be accessed.


PROT_NONE可以用来实现guard pages,微软有同样的概念(MSDN).


… allocation of additional inaccessible memory during memory allocation
operations is a technique for mitigating against exploitation of heap
buffer overflows. These guard pages are unmapped pages placed between
all memory allocations of one page or larger. The guard page causes a
segmentation fault upon any access.

因此在实现对诸如网络接口,虚拟机和解释器等领域的保护方面非常有用.示例用法:pthread_attr_setguardsize, pthread_attr_getguardsize.

转载注明原文:linux – mmap内存保护的目的是什么PROT_NONE - 代码日志