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