]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] msync correctness fixes
authorAndrew Morton <akpm@digeo.com>
Sun, 13 Oct 2002 09:59:04 +0000 (02:59 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sun, 13 Oct 2002 09:59:04 +0000 (02:59 -0700)
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."

mm/msync.c

index 7559fb30a0627eeb7f5745ae4104216e62b98dde..3674d92253d5e93b218df5503180359c5f567923 100644 (file)
@@ -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;