views:

166

answers:

1

Hi, I'm tackling a trivial buffer overflow (yes, exploitation; but unrelated to the problem) I'm trying to figure out the fields in the memory map, when GCC's stack protector is enabled. As an illustration:

$ ./overflow
*** stack smashing detected ***: ./overflow terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb7f67da8]
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x0)[0xb7f67d60]
./overflow[0x804845c]
[0x41414141]
======= Memory map: ========
08048000-08049000 r-xp 00000000 08:06 3704767    /home/hatred/w0rk/bugz
08049000-0804a000 r--p 00000000 08:06 3704767    /home/hatred/w0rk/bugz
0804a000-0804b000 rw-p 00001000 08:06 3704767    /home/hatred/w0rk/bugz
0804b000-0806c000 rw-p 0804b000 00:00 0          [heap]
b7e5a000-b7e67000 r-xp 00000000 08:06 368705     /lib/libgcc_s.so.1
b7e67000-b7e68000 r--p 0000c000 08:06 368705     /lib/libgcc_s.so.1
b7e68000-b7e69000 rw-p 0000d000 08:06 368705     /lib/libgcc_s.so.1
b7e69000-b7e6a000 rw-p b7e69000 00:00 0 
b7e6a000-b7fc6000 r-xp 00000000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc6000-b7fc7000 ---p 0015c000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc7000-b7fc9000 r--p 0015c000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fc9000-b7fca000 rw-p 0015e000 08:06 386037     /lib/tls/i686/cmov/libc-2.9.so
b7fca000-b7fcd000 rw-p b7fca000 00:00 0 
b7fdf000-b7fe1000 rw-p b7fdf000 00:00 0 
b7fe1000-b7fe2000 r-xp b7fe1000 00:00 0          [vdso]
b7fe2000-b7ffe000 r-xp 00000000 08:06 368654     /lib/ld-2.9.so
b7ffe000-b7fff000 r--p 0001b000 08:06 368654     /lib/ld-2.9.so
b7fff000-b8000000 rw-p 0001c000 08:06 368654     /lib/ld-2.9.so
bffeb000-c0000000 rw-p bffeb000 00:00 0          [stack]
Aborted

So, as you can see; There's the backtrace, and then there's the memory map, with 5 fields, and then an optional sixth one which may include a .so.1 (shared libraries?) I'm asking about what these fields are, and what they mean, like the hex fields, and what rw-p means, etc.

I've gone on google and searched but nothing like this comes up.

Thanks.

+6  A: 

Check out the man page for the /proc filesystem, it has all the info you need:

/proc/[number]/maps A file containing the currently mapped memory regions and their access permissions.

The format is:

address           perms offset  dev   inode      pathname
08048000-08056000 r-xp 00000000 03:0c 64593      /usr/sbin/gpm
08056000-08058000 rw-p 0000d000 03:0c 64593      /usr/sbin/gpm
08058000-0805b000 rwxp 00000000 00:00 0
40000000-40013000 r-xp 00000000 03:0c 4165       /lib/ld-2.2.4.so
40013000-40015000 rw-p 00012000 03:0c 4165       /lib/ld-2.2.4.so
4001f000-40135000 r-xp 00000000 03:0c 45494      /lib/libc-2.2.4.so
40135000-4013e000 rw-p 00115000 03:0c 45494      /lib/libc-2.2.4.so
4013e000-40142000 rw-p 00000000 00:00 0
bffff000-c0000000 rwxp 00000000 00:00 0

where address is the address space in the process that it occupies, perms

is a set of permissions:

r = read
w = write
x = execute
s = shared
p = private (copy on write)

offset is the offset into the file/whatever, dev is the device

(major:minor), and inode is the inode on that device. 0 indicates that no inode is associated with the memory region, as the case would be with bss.

Keith Randall