mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-31 23:11:09 +00:00
hurd: permit to use mlock from non-root process
* sysdeps/mach/hurd/mlock.c (mlock): When __get_privileged_ports returns an error, also try to use host port from __mach_host_self for the __vm_wire call. * sysdeps/mach/hurd/munlock.c (munlock): Likewise.
This commit is contained in:
parent
b8528e771c
commit
ed4060f50e
@ -1,3 +1,10 @@
|
||||
2015-07-09 Samuel Thibault <samuel.thibault@ens-lyon.org>
|
||||
|
||||
* sysdeps/mach/hurd/mlock.c (mlock): When __get_privileged_ports
|
||||
returns an error, also try to use host port from __mach_host_self for
|
||||
the __vm_wire call.
|
||||
* sysdeps/mach/hurd/munlock.c (munlock): Likewise.
|
||||
|
||||
2015-07-09 Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
|
||||
[BZ #18400]
|
||||
|
@ -28,19 +28,20 @@
|
||||
int
|
||||
mlock (const void *addr, size_t len)
|
||||
{
|
||||
mach_port_t hostpriv;
|
||||
mach_port_t host;
|
||||
vm_address_t page;
|
||||
error_t err;
|
||||
|
||||
err = __get_privileged_ports (&hostpriv, NULL);
|
||||
err = __get_privileged_ports (&host, NULL);
|
||||
if (err)
|
||||
return __hurd_fail (EPERM);
|
||||
host = __mach_host_self();
|
||||
|
||||
page = trunc_page ((vm_address_t) addr);
|
||||
len = round_page ((vm_address_t) addr + len) - page;
|
||||
err = __vm_wire (hostpriv, __mach_task_self (), page, len,
|
||||
VM_PROT_READ);
|
||||
__mach_port_deallocate (__mach_task_self (), hostpriv);
|
||||
|
||||
err = __vm_wire (host, __mach_task_self (), page, len, VM_PROT_READ);
|
||||
if (host != __mach_host_self())
|
||||
__mach_port_deallocate (__mach_task_self (), host);
|
||||
|
||||
return err ? __hurd_fail (err) : 0;
|
||||
}
|
||||
|
@ -27,18 +27,20 @@
|
||||
int
|
||||
munlock (const void *addr, size_t len)
|
||||
{
|
||||
mach_port_t hostpriv;
|
||||
mach_port_t host;
|
||||
vm_address_t page;
|
||||
error_t err;
|
||||
|
||||
err = __get_privileged_ports (&hostpriv, NULL);
|
||||
err = __get_privileged_ports (&host, NULL);
|
||||
if (err)
|
||||
return __hurd_fail (EPERM);
|
||||
host = __mach_host_self();
|
||||
|
||||
page = trunc_page ((vm_address_t) addr);
|
||||
len = round_page ((vm_address_t) addr + len) - page;
|
||||
err = __vm_wire (hostpriv, __mach_task_self (), page, len, VM_PROT_NONE);
|
||||
__mach_port_deallocate (__mach_task_self (), hostpriv);
|
||||
|
||||
err = __vm_wire (host, __mach_task_self (), page, len, VM_PROT_NONE);
|
||||
if (host != __mach_host_self())
|
||||
__mach_port_deallocate (__mach_task_self (), host);
|
||||
|
||||
return err ? __hurd_fail (err) : 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user