Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jul 2007 09:16:21 +0100 (BST)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Nicolas Cormier <n.cormier@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: p_vmspace in syscall
Message-ID:  <20070704091349.T42421@fledge.watson.org>
In-Reply-To: <c4630b800707020954s4aa0be68t2d5f3eb864f2dda5@mail.gmail.com>
References:  <c4630b800707020954s4aa0be68t2d5f3eb864f2dda5@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Mon, 2 Jul 2007, Nicolas Cormier wrote:

> I am trying to map some data allocated in kernel to a user process (via a 
> syscall). I need the proc's vmspace, but the value of p_vmspace of the input 
> proc argument is NULL ... How can I get a valid vmspace ?

When operating in a system call, the 'td' argument to the system call function 
is the current thread pointer.  You can follow td->td_proc to get to the 
current process (and therefore, its address space).  In general, I prefer 
mapping user pages into kernel instead of kernel pages into user space, as it 
reduces the chances of leakage of kernel data to user space, and there are 
some useful primitives for making this easier.  For example, take a look at 
the sf_buf infrastructure used for things like socket zero-copy send, which 
manages a temporary kernel mapping for a page.

Robert N M Watson
Computer Laboratory
University of Cambridge



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