Commit 9343c8e2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] msync(bad address) should return -ENOMEM

Heaven knows why, but that's what the opengroup say, and returning
-EFAULT causes 2.5 to fail one of the Linux Test Project tests.

[ENOMEM]
          The addresses in the range starting at addr and continuing
          for len bytes are outside the range allowed for the address
          space of a process or specify one or more pages that are not
          mapped.

2.4 has it right, but 2.5 doesn't.
parent df01cd17
......@@ -169,7 +169,7 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
{
unsigned long end;
struct vm_area_struct * vma;
int unmapped_error, error = -EINVAL;
int unmapped_error, error = -ENOMEM;
down_read(&current->mm->mmap_sem);
if (start & ~PAGE_MASK)
......@@ -185,18 +185,18 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
goto out;
/*
* If the interval [start,end) covers some unmapped address ranges,
* just ignore them, but return -EFAULT at the end.
* just ignore them, but return -ENOMEM at the end.
*/
vma = find_vma(current->mm, start);
unmapped_error = 0;
for (;;) {
/* Still start < end. */
error = -EFAULT;
error = -ENOMEM;
if (!vma)
goto out;
/* Here start < vma->vm_end. */
if (start < vma->vm_start) {
unmapped_error = -EFAULT;
unmapped_error = -ENOMEM;
start = vma->vm_start;
}
/* Here vma->vm_start <= start < vma->vm_end. */
......@@ -220,5 +220,3 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
up_read(&current->mm->mmap_sem);
return error;
}
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