c - about the /proc/xx/map and the vm_area_struct -



c - about the /proc/xx/map and the vm_area_struct -

the kernel module code:

static int __init module(void) { struct pid *current_pid; struct task_struct *current_task; struct mm_struct *mymm; struct vm_area_struct *pos = null; current_pid = find_vpid(7887); current_task = pid_task(current_pid, pidtype_pid); mymm = current_task->mm; for(pos = mymm->mmap; pos; pos = pos->vm_next) { printk("0x%hx-0x%hx\t%ld\t", pos->vm_start, pos->vm_end,pos->rb_subtree_gap); if(pos->vm_flags & vm_read) { printk("r"); } else { printk("-"); } if(pos->vm_flags & vm_write) { printk("w"); } else { printk("-"); } if(pos->vm_flags & vm_exec) { printk("x"); } else { printk("-"); } printk("\n"); } homecoming 0; } static void __exit rmodule(void) { printk(kern_alert"goodbye,world\n"); } module_init(module); module_exit(rmodule);

the result:

oct 9 18:57:43 shui kernel: [14625.861352] 0x400000-0x401000 4194304 r-x oct 9 18:57:43 shui kernel: [14625.861366] 0x600000-0x601000 273183399936 r-- oct 9 18:57:43 shui kernel: [14625.861373] 0x601000-0x602000 0 rw- oct 9 18:57:43 shui kernel: [14625.861379] 0x3f9b600000-0x3f9b620000 273183399936 r-x oct 9 18:57:43 shui kernel: [14625.861386] 0x3f9b820000-0x3f9b821000 140214666838016 r-- oct 9 18:57:43 shui kernel: [14625.861391] 0x3f9b821000-0x3f9b822000 0 rw- oct 9 18:57:43 shui kernel: [14625.861397] 0x3f9b822000-0x3f9b823000 0 rw- oct 9 18:57:43 shui kernel: [14625.861403] 0x3f9ba00000-0x3f9bbad000 1953792 r-x oct 9 18:57:43 shui kernel: [14625.861408] 0x3f9bbad000-0x3f9bdad000 0 --- oct 9 18:57:43 shui kernel: [14625.861414] 0x3f9bdad000-0x3f9bdb1000 140214666838016 r-- oct 9 18:57:43 shui kernel: [14625.861419] 0x3f9bdb1000-0x3f9bdb3000 0 rw- oct 9 18:57:43 shui kernel: [14625.861425] 0x3f9bdb3000-0x3f9bdb8000 140214666838016 rw- oct 9 18:57:43 shui kernel: [14625.861431] 0x7fc5e1444000-0x7fc5e1447000 140214666838016 rw- oct 9 18:57:43 shui kernel: [14625.861436] 0x7fc5e146f000-0x7fc5e1470000 140214666838016 rw- oct 9 18:57:43 shui kernel: [14625.861442] 0x7fffe4c32000-0x7fffe4c54000 249166569472 rw- oct 9 18:57:43 shui kernel: [14625.861448] 0x7fffe4d79000-0x7fffe4d7b000 1200128 r-x

but utilize cat /proc/7887/maps:

shui @ kernel @ 19:00]$ cat /proc/7887/maps 00400000-00401000 r-xp 00000000 00:20 1826951 /tmp/a.out 00600000-00601000 r--p 00000000 00:20 1826951 /tmp/a.out 00601000-00602000 rw-p 00001000 00:20 1826951 /tmp/a.out 3f9b600000-3f9b620000 r-xp 00000000 fd:01 2228400 /usr/lib64 /ld-2.16.so 3f9b820000-3f9b821000 r--p 00020000 fd:01 2228400 /usr/lib64/ld-2.16.so 3f9b821000-3f9b822000 rw-p 00021000 fd:01 2228400 /usr/lib64/ld-2.16.so 3f9b822000-3f9b823000 rw-p 00000000 00:00 0 3f9ba00000-3f9bbad000 r-xp 00000000 fd:01 2228403 /usr/lib64/libc-2.16.so 3f9bbad000-3f9bdad000 ---p 001ad000 fd:01 2228403 /usr/lib64/libc-2.16.so 3f9bdad000-3f9bdb1000 r--p 001ad000 fd:01 2228403 /usr/lib64/libc-2.16.so 3f9bdb1000-3f9bdb3000 rw-p 001b1000 fd:01 2228403 /usr/lib64/libc-2.16.so 3f9bdb3000-3f9bdb8000 rw-p 00000000 00:00 0 7fc5e1444000-7fc5e1447000 rw-p 00000000 00:00 0 7fc5e146f000-7fc5e1470000 rw-p 00000000 00:00 0 7fffe4c33000-7fffe4c54000 rw-p 00000000 00:00 0 [stack] 7fffe4d79000-7fffe4d7b000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

the vm_area_struct stack address 7fffe4c32000, maps 7fffe4c33000, different this? , vsyscall why donot printf on vm_area_struct ?

it normal, linux kernel uses stack guard , procfs not show page.

see function show_map_vma in fs/proc/task_mmu.c

c linux linux-kernel kernel

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -