Commit 59791303 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] msync correctness fixes

From Anton Blanchard.  This fixes a couple of Linux Test Project
failures.

- Returns EBUSY if the caller is trying to invalidate memory which is
  covered by a locked vma.

  The open group say:

  [EBUSY]
          Some or all of the addresses in the range starting
          at addr and continuing for len bytes are locked,
          and MS_INVALIDATE is specified.

- Returns EINVAL if the caller specified both MS_SYNC and MS_ASYNC

  [EINVAL]
          The value of flags is invalid.

  and:

          "Either MS_ASYNC or MS_SYNC is specified, but not both."
parent 0e296d85
......@@ -137,6 +137,9 @@ static int msync_interval(struct vm_area_struct * vma,
int ret = 0;
struct file * file = vma->vm_file;
if ((flags & MS_INVALIDATE) && (vma->vm_flags & VM_LOCKED))
return -EBUSY;
if (file && (vma->vm_flags & VM_SHARED)) {
ret = filemap_sync(vma, start, end-start, flags);
......@@ -173,6 +176,8 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
goto out;
if (start & ~PAGE_MASK)
goto out;
if ((flags & MS_ASYNC) && (flags & MS_SYNC))
goto out;
error = -ENOMEM;
len = (len + ~PAGE_MASK) & PAGE_MASK;
end = start + len;
......
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