Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
608 views
in Technique[技术] by (71.8m points)

memory management - /proc/$pid/maps shows pages with no rwx permissions on x86_64 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.

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!

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

please advise.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

These mappings are used for shared libraries:

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

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).

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...