Commit e77414e0aad6a1b063ba5e5750c582c75327ea6a

Authored by Al Viro
1 parent bb52d66940

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

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>

Showing 4 changed files with 8 additions and 4 deletions Side-by-side Diff

... ... @@ -54,7 +54,8 @@
54 54 * We enforce the MAP_FIXED case.
55 55 */
56 56 if (flags & MAP_FIXED) {
57   - if (aliasing && flags & MAP_SHARED && addr & (SHMLBA - 1))
  57 + if (aliasing && flags & MAP_SHARED &&
  58 + (addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1))
58 59 return -EINVAL;
59 60 return addr;
60 61 }
arch/mips/kernel/syscall.c
... ... @@ -93,7 +93,8 @@
93 93 * We do not accept a shared mapping if it would violate
94 94 * cache aliasing constraints.
95 95 */
96   - if ((flags & MAP_SHARED) && (addr & shm_align_mask))
  96 + if ((flags & MAP_SHARED) &&
  97 + ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask))
97 98 return -EINVAL;
98 99 return addr;
99 100 }
... ... @@ -54,7 +54,8 @@
54 54 /* We do not accept a shared mapping if it would violate
55 55 * cache aliasing constraints.
56 56 */
57   - if ((flags & MAP_SHARED) && (addr & shm_align_mask))
  57 + if ((flags & MAP_SHARED) &&
  58 + ((addr - (pgoff << PAGE_SHIFT)) & shm_align_mask))
58 59 return -EINVAL;
59 60 return addr;
60 61 }
arch/sparc/kernel/sys_sparc_32.c
... ... @@ -45,7 +45,8 @@
45 45 /* We do not accept a shared mapping if it would violate
46 46 * cache aliasing constraints.
47 47 */
48   - if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1)))
  48 + if ((flags & MAP_SHARED) &&
  49 + ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
49 50 return -EINVAL;
50 51 return addr;
51 52 }