加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-13 18:12:35 所属栏目:Linux 来源:网络整理
导读:我正在阅读mmap的 documentation,并落在这条线上: PROT_NONE Pages may not be accessed. 有没有用来将文件映射到内存,但是不能访问它? 解决方法 PROT_NONE可以用来实现 guard pages,微软有同样的概念( MSDN). 引用第一个链接: … allocation of addition
我正在阅读mmap的 documentation,并落在这条线上:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读