免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3679 | 回复: 8
打印 上一主题 下一主题

[内存管理] 有关匿名页的反向映射的一个疑惑 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-05-08 10:14 |只看该作者 |倒序浏览
在ULK中提到匿名共享页的线性地址是由:匿名线性区起始地址+page-->index,从而获得共享页的页表项。但我有个疑惑:一个page结构只有一个index字段,难道匿名共享页映射到不同的匿名内存区其index一定要相同吗?附上书上的一个图

论坛徽章:
1
双鱼座
日期:2013-08-28 13:47:26
2 [报告]
发表于 2012-05-08 10:52 |只看该作者
The mremap( ) system call may remap memory regions and move the pages into the User Mode address space by directly modifying the page table entries. In this particular case, object-based reverse mapping does not work, because the index field of the page descriptor cannot be used to determine the actual linear address of the page.

论坛徽章:
0
3 [报告]
发表于 2012-05-08 10:54 |只看该作者
看这句话的意思,应该是要求所有的index必须一样,是吧回复 2# firkraag


   

论坛徽章:
1
双鱼座
日期:2013-08-28 13:47:26
4 [报告]
发表于 2012-05-08 11:02 |只看该作者
上面的English是书里的有的原话。匿名内存映射适用于具有亲属关系的进程之间.要是有亲属关系的话,我觉得这个index就应该相同了。

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
5 [报告]
发表于 2012-05-24 15:03 |只看该作者
回复 3# flikelinux



对于匿名页的page->index表示的是page在vma中的偏移。共享匿名页的产生应该只有在fork,clone等时候。也就是说获得了parent process的VMAs。那么应该是一样的啊!


   

论坛徽章:
16
2015亚冠之吉达阿赫利
日期:2015-08-17 11:21:462015年迎新春徽章
日期:2015-03-04 09:58:11酉鸡
日期:2014-12-07 09:06:19水瓶座
日期:2014-11-04 14:23:29天秤座
日期:2014-03-02 08:57:52双鱼座
日期:2014-02-22 13:07:56午马
日期:2014-02-14 11:08:18双鱼座
日期:2014-02-13 11:09:37卯兔
日期:2014-02-06 15:10:34子鼠
日期:2014-01-20 14:48:19戌狗
日期:2013-12-19 09:37:46射手座
日期:2013-12-19 09:33:47
6 [报告]
发表于 2012-05-24 15:04 |只看该作者
本帖最后由 embeddedlwp 于 2012-05-24 15:05 编辑

回复 2# firkraag



The mremap( ) system call may remap memory regions and move the pages into the User Mode address space by directly modifying the page table entries. In this particular case, object-based reverse mapping does not work, because the index field of the page descriptor cannot be used to determine the actual linear address of the page.


红色的部分怎么理解呢?与其他的方式比如mmap有什么区别?

论坛徽章:
1
双鱼座
日期:2013-08-28 13:47:26
7 [报告]
发表于 2012-05-24 17:59 |只看该作者
本帖最后由 firkraag 于 2012-05-24 18:06 编辑

http://isec.pl/vulnerabilities/isec-0014-mremap-unmap.txt
Details:
========

The Linux kernel manages a list of user addressable valid memory locations on a
per process basis. Every process owns a single linked list of so called virtual
memory area descriptors (called from now on just VMAs). Every VMA describes the
start of a valid memory region, its length and moreover various memory flags
like page protection.

Every VMA in the list corresponds to a part of the process's page table. The
page table contains descriptors (in short page table entries PTEs) of physical
memory pages seen by the process. The VMA descriptor can be thus understood as a
high level description of a particular region of the process's page table
storing PTE properties like page R/W flag and so on.

The mremap() system call provides resizing (shrinking or growing) as well as
moving of existing virtual memory areas or any of its parts across process's
addressable space.

Moving a part of the virtual memory from inside a VMA area to a new location
requires creation of a new VMA descriptor as well as copying the underlying page
table entries described by the VMA from the old to the new location in the
process's page table.
......

论坛徽章:
1
双鱼座
日期:2013-08-28 13:47:26
8 [报告]
发表于 2012-05-24 19:34 |只看该作者
就是说该函数的功能之一是可以将一个vma的某部分移动到进程的其它地址空间中。

论坛徽章:
2
2016猴年福章徽章
日期:2016-02-18 15:30:3415-16赛季CBA联赛之广夏
日期:2016-12-07 08:32:11
9 [报告]
发表于 2017-01-01 18:37 |只看该作者
我也正有此疑惑
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP