[patch] unprivileged mlock(2)

Don Lewis truckman at FreeBSD.org
Wed Aug 29 09:06:30 UTC 2012


On 29 Aug, Andrey Zonov wrote:

> But can we do better and don't lock process's memory in sysctl handlers?

It is necessary to wire the userland buffer to make sure that the sysctl
handler doesn't page fault while it is copying data into or out of the
buffer.  The handler may be holding a mutex that protects the kernel
data structure that it is accessing, in which case the handler is not
allowed to block on a page fault.

If the handler allocated a buffer in kernel memory before grabbing the
mutex, the it would be possible to avoid wiring the userland buffer, but
this would tie up just as much non-pageable memory and an extra data
copy would be required.




More information about the freebsd-arch mailing list