From owner-freebsd-questions Mon Aug 4 18:03:20 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id SAA09747 for questions-outgoing; Mon, 4 Aug 1997 18:03:20 -0700 (PDT) Received: from implode.root.com (implode.root.com [198.145.90.17]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id SAA09741 for ; Mon, 4 Aug 1997 18:03:15 -0700 (PDT) Received: from implode.root.com (localhost [127.0.0.1]) by implode.root.com (8.8.5/8.8.5) with ESMTP id SAA17245; Mon, 4 Aug 1997 18:05:03 -0700 (PDT) Message-Id: <199708050105.SAA17245@implode.root.com> To: rtwalsh@ix.netcom.com cc: questions@FreeBSD.ORG Subject: Re: mmap and MAP_ANON In-reply-to: Your message of "Mon, 04 Aug 1997 19:22:36 CDT." <199784172215241@> From: David Greenman Reply-To: dg@root.com Date: Mon, 04 Aug 1997 18:05:03 -0700 Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >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