[patch] unprivileged mlock(2)

Konstantin Belousov kostikbel at gmail.com
Wed Aug 29 09:23:26 UTC 2012


On Wed, Aug 29, 2012 at 02:06:12AM -0700, Don Lewis wrote:
> 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.

At least it would not cause a fragmentation of the user map.

Another approach could be to use vm_fault_quick_hold_pages() and then
use uiomove_fromphys() to copyin/out data inside the handler. This is
what currently done by FFS and NFS.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20120829/df5fb564/attachment.pgp


More information about the freebsd-arch mailing list