/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.
/proc/PID/mem gives access to the memory of the process as it is mapped in the process: accessing the Nth byte of this file is equivalent to accessing (*unsigned char)N inside the process in C, or ptrace(PTRACE_PEEKDATA, PID, (void*)N, NULL) from another process (or PTRACE_POKEDATA for writing, and with the difference ...
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With