Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Errno for munlock(2) on unlocked mapping ?
Hi,
While checking some compat linux stuff, i exercized native munlock(2)
behavior ... And noted a small issue with returned errno with unlocked
mapping.
The man page states that it should fail with ENOMEM :
[ENOMEM] Some portion of the indicated address range is not
allocated. Some portion of the indicated address
range is not locked.
But code disagree as EINVAL is returned (from uvm_map_pageable()) for
the attached testcase :
10066 1 munlock CALL mmap(0,0x1000,7,0x1002,0xffffffff,0,0)
10066 1 munlock RET mmap 140187598286848/0x7f7ff7ff7000
10066 1 munlock CALL munlock(0x7f7ff7ff7000,0x1000)
10066 1 munlock RET munlock -1 errno 22 Invalid argument
10066 1 munlock CALL munmap(0x7f7ff7ff7000,0x1000)
10066 1 munlock RET munmap 0
Digging into history, this small behaviour change was introduced in
2001 (sys_mmap.c rev 1.50) with KERN_* error codes removal.
@@ -988,7 +947,7 @@ sys_munlock(p, v, retval)
error = uvm_map_pageable(&p->p_vmspace->vm_map, addr, addr+size, TRUE,
0);
- return (error == KERN_SUCCESS ? 0 : ENOMEM);
+ return error;
}
Not sure who's right there ... EINVAL or ENOMEM ?
Thanks.
--
Nicolas Joly
Biology IT Center
Institut Pasteur, Paris.
#include <sys/mman.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#define PROT_ALL (PROT_WRITE|PROT_READ|PROT_EXEC)
int main() {
void *adr;
size_t len;
len = getpagesize();
adr = mmap(NULL, len, PROT_ALL, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
assert(adr != MAP_FAILED);
munlock(adr, len);
assert(munmap(adr, len) != -1);
return 0; }
Home |
Main Index |
Thread Index |
Old Index