[lkml]   [1997]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: mmap(MAP_SHARED | MAP_ANON) broke!

> > There is also another solution (That's a real hack).
> > x = mmap(..., MAP_ANON |MAP_PRIVATE, ...);
> > fd = open("/proc/self/mem");
> > y = mmap(...., MAP_SHARED, ..., fd, x);
> > munmap(x);
> This didn't work for me... I also tried forking and then
> mmap-ing() the
> space out of the other processes /proc/.../mem--
> Any idea what's going on (code attached).

Without a source tree at work, I can only guess from memory (no
pun intended :)

Check in proc/fs, there is a file which implements the
file operations for /proc/pid|self/* (it's probably called mem.c).
There is a func for mmap() ops on /proc/*/mem, which has a few
restrictions. One of the limitations (if I remember correctly),
is that the pte's in the range being mapped must be present (ie.
pte_none() needs to return zero).
The anon mapping will not fill out any pte's in the mapped range,
so this maybe why the second mmap() fails.

After mmap(..,MAP_ANON...), try touching each page. A read might
be succifient (it will set the pte's to point to the ZERO page), if
that doesn't work try a write to each page.

Also, it's probably worth checking your rlimits (although that should
return -ENMEM (12), not the 22 you are seeing).

Best of luck,


 \ /
  Last update: 2005-03-22 13:38    [W:0.015 / U:1.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site