fix broken aliasing checks for MAP_FIXED on sparc32, mips, arm and sh
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 5 Dec 2009 20:10:44 +0000 (15:10 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 11 Dec 2009 11:44:59 +0000 (06:44 -0500)
We want addr - (pgoff << PAGE_SHIFT) consistently coloured...

Acked-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/arm/mm/mmap.c
arch/mips/kernel/syscall.c
arch/sh/mm/mmap.c
arch/sparc/kernel/sys_sparc_32.c

index 2b7996401b0f9f602dfa2d809f86e40b57f79117..f5abc51c5a07ff24e047ef333c7dd47b942fc3a4 100644 (file)
@@ -54,7 +54,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
         * We enforce the MAP_FIXED case.
         */
        if (flags & MAP_FIXED) {
-               if (aliasing && flags & MAP_SHARED && addr & (SHMLBA - 1))
+               if (aliasing && flags & MAP_SHARED &&
+                   (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1))
                        return -EINVAL;
                return addr;
        }
index c25b2e7dcb7b42a69690505db6bd08e3788e7e30..3f7f466190b481e62b7df738b10ef96477f1c059 100644 (file)
@@ -93,7 +93,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
                 * We do not accept a shared mapping if it would violate
                 * cache aliasing constraints.
                 */
-               if ((flags & MAP_SHARED) && (addr & shm_align_mask))
+               if ((flags & MAP_SHARED) &&
+                   ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask))
                        return -EINVAL;
                return addr;
        }
index d2984fa42d3d0ee69fce3a3e0a7e4fa24323c835..afeb710ec5c35d06926717a7f666f373ea366887 100644 (file)
@@ -54,7 +54,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
                /* We do not accept a shared mapping if it would violate
                 * cache aliasing constraints.
                 */
-               if ((flags & MAP_SHARED) && (addr & shm_align_mask))
+               if ((flags & MAP_SHARED) &&
+                   ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask))
                        return -EINVAL;
                return addr;
        }
index 997bdd0d3d7004655ce26ff5350e05131215f2b9..3a82e65d8db2072b9f4b3d9a2edb9faf55c263a7 100644 (file)
@@ -45,7 +45,8 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
                /* We do not accept a shared mapping if it would violate
                 * cache aliasing constraints.
                 */
-               if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1)))
+               if ((flags & MAP_SHARED) &&
+                   ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
                        return -EINVAL;
                return addr;
        }