p_vmspace in syscall
Robert Watson
rwatson at FreeBSD.org
Wed Jul 4 08:48:04 UTC 2007
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
More information about the freebsd-hackers
mailing list