Skip to contentSkip to conversation

powerpc: ppc64 address space capped at 32TB, mmap randomisation disabled

PATCH In review Anton Blanchard 2 participants 2 messages Nov 18, 2013 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: ppc64 address space capped at 32TB, mmap randomisation disabled

Commit fba2369e6ceb (mm: use vm_unmapped_area() on powerpc architecture) has a bug in slice_scan_available() where we compare an unsigned long (high_slices) against a shifted int. As a result, comparisons against the top 32 bits of high_slices (representing the top 32TB) always returns 0 and the top of our mmap region is clamped at 32TB

This also breaks mmap randomisation since the randomised address is always up near the top of the address space and it gets clamped down to 32TB.

---

arch/powerpc/mm/slice.c +1 -1
index 3e99c14..7ce9cf3 100644
@@ -258,7 +258,7 @@ static bool slice_scan_available(unsigned long addr,
 		slice = GET_HIGH_SLICE_INDEX(addr);
 		*boundary_addr = (slice + end) ?
 			((slice + end) << SLICE_HIGH_SHIFT) : SLICE_LOW_TOP;
-		return !!(available.high_slices & (1u << slice));
+		return !!(available.high_slices & (1ul << slice));
 	}
 }
 
Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Anton Blanchard

Commit fba2369e6ceb (mm: use vm_unmapped_area() on powerpc architecture) has a bug in slice_scan_available() where we compare an unsigned long (high_slices) against a shifted int. As a result, comparisons against the top 32 bits of high_slices (representing the top 32TB) always returns 0 and the top of our mmap region is clamped at 32TB

This also breaks mmap randomisation since the randomised address is always up near the top of the address space and it gets clamped down to 32TB.

---

arch/powerpc/mm/slice.c +0 -0
index 3e99c14..7ce9cf3 100644

arch/powerpc/mm/slice.c static bool slice_scan_available(unsigned long addr, · line 264

Quoted 8 lines
arch/powerpc/mm/slice.c +1 -1
@@ -258,7 +258,7 @@ static bool slice_scan_available(unsigned long addr,
                slice = GET_HIGH_SLICE_INDEX(addr);
                *boundary_addr = (slice + end) ?
                        ((slice + end) << SLICE_HIGH_SHIFT) : SLICE_LOW_TOP;
-               return !!(available.high_slices & (1u << slice));
+               return !!(available.high_slices & (1ul << slice));
        }
 }
 

Good catch, sorry about that...

Signature · 2 lines
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.