Commit 964f2d4d authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[PATCH] error code for mprotect()

SuSv3 says: "The mprotect() function shall fail if:

  [EACCES]
    The prot argument specifies a protection that violates the access
    permission the process has to the underlying memory object.

  [EAGAIN]
    The prot argument specifies PROT_WRITE over a MAP_PRIVATE mapping and
    there are insufficient memory resources to reserve for locking the
    private page.

  [EINVAL]
    The addr argument is not a multiple of the page size as returned by
    sysconf().

  [ENOMEM]
    Addresses in the range [addr,addr+len) are invalid for the address
    space of a process, or specify one or more pages which are not mapped.

  [ENOMEM]
    The prot argument specifies PROT_WRITE on a MAP_PRIVATE mapping, and
    it would require more space than the system is able to supply for
    locking the private pages, if required.

  [ENOTSUP]
    The implementation does not support the combination of accesses
    requested in the prot argument."

This fixes error code of mprotect() of the ENOMEM case.
parent 8375eba2
......@@ -290,7 +290,7 @@ asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot
down_write(&current->mm->mmap_sem);
vma = find_vma_prev(current->mm, start, &prev);
error = -EFAULT;
error = -ENOMEM;
if (!vma || vma->vm_start > start)
goto out;
......@@ -323,7 +323,7 @@ asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot
nstart = tmp;
vma = next;
if (!vma || vma->vm_start != nstart) {
error = -EFAULT;
error = -ENOMEM;
goto out;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment