Re: [test patch] dirty shared mappings

Linus Torvalds (torvalds@transmeta.com)
Fri, 9 Jan 1998 10:14:38 -0800 (PST)


On Fri, 9 Jan 1998, Thomas Sailer wrote:
> >
> > Really? I thought the standard UNIX shared memory definition was more like
> > a shared memory block that has a public key (ie I thought _everybody_ got
> > the shared memory area, not just children).
>
> Everybody (with perms) can get it as long as it's not "unlinked"
> (IPC_RMID). IPC_RMID removes the key (so no one new may attach),
> but the segment retains until the last one unmaps it.
> Don't know what happens on a fork after IPC_RMID, but I would
> be very surprised if the child wouldn't get it mapped into
> its address space.

Note that when I'm saying "UNIX anonymous shared memory" as opposed to
"SysV shmem" I'm talking about something like this:

char * addr = mmap(NULL, 8192,
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS,
-1, 0);

And I thought that _everything_ shared the same page pool with no
protection checks (ie different processes that aren't related would get
the same shared pages).

But if the above only gets a "private" shared memory area (ie only passed
down as a shared memory area through fork(), not accessible through other
unrelated processes doing the same mmap()), then it is not as braindamaged
as I thought it was.

Linus