Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Aug 1997 19:22:36 -0500 (CDT)
From:      rtwalsh@ix.netcom.com
To:        questions@freebsd.org
Subject:   mmap and MAP_ANON
Message-ID:  <199784172215241@>

next in thread | raw e-mail | index | archive | help
Hello there,

Sorry to bug you with a question, but I couldn't find the answer anywhere, so here goes:

I am trying to create a "named" memory map, with the name being "69", as in the function call 
below:

  pMem1 = mmap( NULL, 100000, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, 69, 0 );

However, this does not work (returns -1, with errno 22 (invalid argument)).  If I use the invalid 
fd of -1, then it does work, but then it is not named and I cannot get at this memory map from 
another process.  The man page for mmap() suggests that I should be able to do this:

MAP_ANON    Map anonymous memory not associated with any specific file.
            The file descriptor used for creating MAP_ANON regions is
            used only for naming, and may be specified as -1 if no name
            is associated with the region.

I am using FreeBSD 2.1.6.  Is there a bug with this particular feature, or am I missing something?

If you cannot help me with this particular problem, perhaps you can give me a suggestion as to how 
to solve the problem that I am trying to use this mmap for.  I need to share memory between 
processes and the data in the memory is confidential, thus the shared memory functions (shmget(), 
etc.) are not appropriate, since anyone can use ipcs -m to get the shared memory id and write a 
tiny program to go get the contents of the shared memory.  Any suggestions as to how I can get a 
moderately secure block of shared memory?

Many thanks for your time,

Robin.

---------------------
Robin Walsh
rtwalsh@ix.netcom.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199784172215241>