Skip to contentSkip to conversation

fix broken aliasing checks for MAP_FIXED on sparc32, mips, arm and sh

PATCH In review Al Viro 2 participants 2 messages Dec 5, 2009

Subsystems (5)
lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 fix broken aliasing checks for MAP_FIXED on sparc32, mips, arm and sh

We want addr - (pgoff << PAGE_SHIFT) consistently coloured... BTW, sparc64 is correct, sparc32 isn't.

---
[On top of the mmap/mremap series, but should apply to mainline modulo line numbers shift]

 arch/arm/mm/mmap.c               |    3 ++-
 arch/mips/kernel/syscall.c       |    3 ++-
 arch/sh/mm/mmap.c                |    3 ++-
 arch/sparc/kernel/sys_sparc_32.c |    3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)
arch/arm/mm/mmap.c +2 -1
index 2b79964..f5abc51 100644
@@ -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;
 	}
arch/mips/kernel/syscall.c +2 -1
index c25b2e7..3f7f466 100644
@@ -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;
 	}
arch/sh/mm/mmap.c +2 -1
index d2984fa..afeb710 100644
@@ -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;
 	}
arch/sparc/kernel/sys_sparc_32.c +2 -1
index 997bdd0..3a82e65 100644
@@ -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;
 	}
Signature · 1 line
1.5.6.5
#1 lore raw

On Sat, Dec 05, 2009 at 08:15:50PM +0000, Al Viro wrote:

After our IRC chat I've already applied an commit that is identical to the MIPS segment of your patch.

Thanks!

Ralf