解决方法
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.