Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Aug 1997 18:05:03 -0700
From:      David Greenman <dg@root.com>
To:        rtwalsh@ix.netcom.com
Cc:        questions@FreeBSD.ORG
Subject:   Re: mmap and MAP_ANON 
Message-ID:  <199708050105.SAA17245@implode.root.com>
In-Reply-To: Your message of "Mon, 04 Aug 1997 19:22:36 CDT." <199784172215241@> 

next in thread | previous 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,

   Named anonymous regions are not supported in FreeBSD. The manual page is
wrong and needs to be updated. You need to use SYSV shared memory; see
shmat/smmget/shmctl.

-DG

David Greenman
Core-team/Principal Architect, The FreeBSD Project



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