/proc/$pid/maps 显示在 x86_64 linux 上没有 rwx 权限的页面 [英] /proc/$pid/maps shows pages with no rwx permissions on x86_64 linux

查看:28
本文介绍了/proc/$pid/maps 显示在 x86_64 linux 上没有 rwx 权限的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/proc/$pid/maps 显示在 x86_64 Linux 上没有 rwx 权限的页面.我注意到当我在 64 位 Linux 上读取 /proc/$pid/maps 时,我有没有权限的内存页,但在 32 位 Linux 中,它们不存在.

/proc/$pid/maps shows pages with no rwx permissions on x86_64 Linux. I noticed that when I read /proc/$pid/maps at 64bit Linux I have memory pages that have no permissions, but in a 32bit Linux, they aren't there.

我正在尝试监控进程的内存使用情况,但我很困惑.为什么有些页面没有 rwx 权限.他们正在消耗我的记忆!

I’m trying to monitor the memory usage of my process, but I'm confused. Why are there pages with no rwx privileges. They are consuming my memory!

这是top"的 64 位 Linux 输出的片段

This is a snippet of the output of a 64bit Linux for ‘top’

% cat /proc/21367/maps

3154200000-315420d000 r-xp 00000000 fd:00 4835776 /lib64/libproc-3.2.7.so <br/>
315420d000-315440d000 **---p** 0000d000 fd:00 4835776 /lib64/libproc-3.2.7.so <br/>
315440d000-315440e000 rw-p 0000d000 fd:00 4835776 /lib64/libproc-3.2.7.so

请指教.

推荐答案

这些映射用于共享库:

通常对于每个加载的共享库,我们将有四个映射:

In general for each shared library loaded we will have four mappings:

3b7cc00000-3b7cd86000 r-xp 00000000 fd:00 661350            /lib64/libc-2.12.so
3b7cd86000-3b7cf86000 ---p 00186000 fd:00 661350            /lib64/libc-2.12.so
3b7cf86000-3b7cf8a000 r--p 00186000 fd:00 661350            /lib64/libc-2.12.so
3b7cf8a000-3b7cf8b000 rw-p 0018a000 fd:00 661350            /lib64/libc-2.12.so

第一个是具有可执行权限的代码段,第二个是PROT_NONE(无权限)映射,最后两个是数据段(只读部分和读写).

The first one is the code segment with executable permissions, the second one the PROT_NONE (no permissions) mapping, and the last two ones the data segment (read only part and read write).

创建 PROT_NONE 映射是为了保持库的有效共享并标记保护页以便可以捕获缓冲区溢出.

The PROT_NONE mappings are created to do with keeping libraries efficiently sharable and to mark guard pages so buffer overflows can be catched.

请记住,这些映射仅使用部分虚拟地址空间,但实际上并未消耗系统内存.

Just keep in mind that these mappings are only using part of the virtual address space but they are not actually consuming the systems memory.

在这里你可以找到一个完整的解释:

Here you can find a complete explanation:

http://www.greenend.org.uk/rjk/tech/dataseg.html

这篇关于/proc/$pid/maps 显示在 x86_64 linux 上没有 rwx 权限的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆