/proc/(PID)/maps (access permissions)
Dave Hylands
dhylands at gmail.com
Thu Oct 13 02:26:18 EDT 2011
Hi Kenijor,
On Wed, Oct 12, 2011 at 7:08 PM, KenjiroNakayama
<nakayamakennjirou at gmail.com> wrote:
> I want to know about /proc/<PID>/maps.
> Whenever I looked at /proc/maps, it is mapping as many types of access
> permissions.
>
> For example:
> /bin/cat => r-wp and rw-p access permissions
> /lib64/ld-2.14.so => r-wp, r-xp and some access permissions)
>
> Why does it need to map some permissions? ( in my opinion,as it maps
> into VM space, it just needs write permission...)
Well, /proc/maps is showing each memory region and what type of
permissions are granted. Code requires read and execute. Data requires
read, and write. Constant data only requires read.
> $ cat /proc/self/maps
>
> 00400000-0040b000 r-xp 00000000 fd:01 925242
> /bin/cat #
If you examine the /bin/cat elf file (using objdump -p /bin/cat and
objdump -h /bin/cat) objdump -p shows the information used by the
loader. You'll notice that the segments have permissions, and these
permissions will correspond to stuff in /proc/self/maps (particularly
the sections that have the LOAD attribute).
You can correlate the virtual addresses from the -p output with the
individual sections shown in the -h ouput.
The r-xp corresponds to code (readable, non writable, executable, private)
> 0060a000-0060b000 rw-p 0000a000 fd:01 925242
> /bin/cat # <= why does it need two type?!
The rw-p will corrspond to data (readable, writable, not executable, private)
> 0060b000-0060c000 rw-p 00000000 00:00 0
> 0080a000-0080b000 rw-p 0000a000 fd:01 925242
> /bin/cat # <= furthermore, it comes again!!!!
This is just an additional memory region with a different set of
addresses from the previous one.
> 02144000-02165000 rw-p 00000000 00:00 0 [heap]
> 3ca7600000-3ca761f000 r-xp 00000000 fd:01 1058940
> /lib64/ld-2.14.so
> 3ca781e000-3ca781f000 r--p 0001e000 fd:01 1058940
> /lib64/ld-2.14.so
> 3ca781f000-3ca7820000 rw-p 0001f000 fd:01 1058940
> /lib64/ld-2.14.so ## <= why three types of access
> permissions?!
Repeat, except this is for a shared-library which has been loaded into
the /bin/cat process space. Shared libraries have code, data, etc.
> 3ca7820000-3ca7821000 rw-p 00000000 00:00 0
> 3ca7e00000-3ca7f8f000 r-xp 00000000 fd:01 1058941
> /lib64/libc-2.14.so
> 3ca7f8f000-3ca818f000 ---p 0018f000 fd:01 1058941
> /lib64/libc-2.14.so
> 3ca818f000-3ca8193000 r--p 0018f000 fd:01 1058941
> /lib64/libc-2.14.so
> 3ca8193000-3ca8194000 rw-p 00193000 fd:01 1058941
> /lib64/libc-2.14.so
--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
More information about the Kernelnewbies
mailing list