From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: mmap in PV xen-4.0.1 Date: Thu, 11 Aug 2011 09:21:09 +0800 Message-ID: <20110811012109.GA1889@limbo> References: <20110810091256.GA1537@limbo> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Eric Camachat Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On Wed, Aug 10, 2011 at 11:31:29AM -0700, Eric Camachat wrote: > >> > >>        switch(cmd) { > >>        case MEMTEST_DMA_SIZE: > >>                size = (uint32_t*)arg; > >>                *size = _size; > > > > Though your output shows that this assignment works, shouldn't this > > kind of direct assignment across kernel space and user land be > > avoided? It is bad practice to do direct assignment I think. > > > > copy_{from,to}_user should do the job. > > > > I want share some memory between kernel and user applications, so I am > trying to use mmap instead of copy_{from,to} multiple times. > I understand. But I still insist you use copy_{from,to}_user when doing syscalls, just to validate the pointer for syscalls. AFAICT, a syscall is not about sharing things, it is about providing service routines to user space. If user space application issues syscall with wrong pointer, your system is likely to get compromised. (well, I major in Information Security so may be to sensitive on this...) When you're running your own application, you can choose whatever method you like to share data between kernel and user land. Wei.