]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix remap of shared read only mappings
authorJames Bottomley <james.bottomley@steeleye.com>
Thu, 4 Sep 2003 03:13:28 +0000 (20:13 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 4 Sep 2003 03:13:28 +0000 (20:13 -0700)
When mmap MAP_SHARED is done on a file, it gets marked with VM_MAYSHARE
and, if it's read/write, VM_SHARED.  However, if it is remapped with
mremap(), the MAP_SHARED is only passed into the new mapping based on
VM_SHARED.  This means that remapped read only MAP_SHARED mappings lose
VM_MAYSHARE.  This is causing us a problem on parisc because we have to
align all shared mappings carefully to mitigate cache aliasing problems.

The fix is to key passing the MAP_SHARED flag back into the remapped are
off VM_MAYSHARE not VM_SHARED.

mm/mremap.c

index d9180f18ad6c44b14b10627d99981b5482663c7d..0412a204cb6919f3f08a4ef67395058adaef67e3 100644 (file)
@@ -420,7 +420,7 @@ unsigned long do_mremap(unsigned long addr,
        if (flags & MREMAP_MAYMOVE) {
                if (!(flags & MREMAP_FIXED)) {
                        unsigned long map_flags = 0;
-                       if (vma->vm_flags & VM_SHARED)
+                       if (vma->vm_flags & VM_MAYSHARE)
                                map_flags |= MAP_SHARED;
 
                        new_addr = get_unmapped_area(vma->vm_file, 0, new_len,