]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
powerpc/mm/radix: Use mm->task_size for boundary checking instead of addr_limit
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Thu, 13 Apr 2017 19:18:21 +0000 (00:48 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 19 Apr 2017 10:00:18 +0000 (20:00 +1000)
We don't init addr_limit correctly for 32 bit applications. So default to using
mm->task_size for boundary condition checking. We use addr_limit to only control
free space search. This makes sure that we do the right thing with 32 bit
applications.

We should consolidate the usage of TASK_SIZE/mm->task_size and
mm->context.addr_limit later.

This partially reverts commit fbfef9027c2a7ad (powerpc/mm: Switch some
TASK_SIZE checks to use mm_context addr_limit).

Fixes: fbfef9027c2a ("powerpc/mm: Switch some TASK_SIZE checks to use mm_context addr_limit")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/mm/hugetlbpage-radix.c
arch/powerpc/mm/mmap.c
arch/powerpc/mm/slice.c
arch/powerpc/mm/subpage-prot.c

index 0aa9cade422f80574569afa33dd6541d235ab6fc..6575b9aabef4df3f0e8903417d121b47c1f2f2a4 100644 (file)
@@ -55,7 +55,7 @@ radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
 
        if (len & ~huge_page_mask(h))
                return -EINVAL;
-       if (len > mm->context.addr_limit)
+       if (len > mm->task_size)
                return -ENOMEM;
 
        if (flags & MAP_FIXED) {
@@ -67,7 +67,7 @@ radix__hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
        if (addr) {
                addr = ALIGN(addr, huge_page_size(h));
                vma = find_vma(mm, addr);
-               if (mm->context.addr_limit - len >= addr &&
+               if (mm->task_size - len >= addr &&
                    (!vma || addr + len <= vma->vm_start))
                        return addr;
        }
index b2111baa0da6cc8c91908d4f8885eacf6cc6daf9..106a86406c7781d34b6e5b86623bd3f5484698ea 100644 (file)
@@ -100,7 +100,7 @@ radix__arch_get_unmapped_area(struct file *filp, unsigned long addr,
        if (unlikely(addr > mm->context.addr_limit && addr < TASK_SIZE))
                mm->context.addr_limit = TASK_SIZE;
 
-       if (len > mm->context.addr_limit - mmap_min_addr)
+       if (len > mm->task_size - mmap_min_addr)
                return -ENOMEM;
 
        if (flags & MAP_FIXED)
@@ -109,7 +109,7 @@ radix__arch_get_unmapped_area(struct file *filp, unsigned long addr,
        if (addr) {
                addr = PAGE_ALIGN(addr);
                vma = find_vma(mm, addr);
-               if (mm->context.addr_limit - len >= addr && addr >= mmap_min_addr &&
+               if (mm->task_size - len >= addr && addr >= mmap_min_addr &&
                    (!vma || addr + len <= vma->vm_start))
                        return addr;
        }
@@ -143,7 +143,7 @@ radix__arch_get_unmapped_area_topdown(struct file *filp,
                mm->context.addr_limit = TASK_SIZE;
 
        /* requested length too big for entire address space */
-       if (len > mm->context.addr_limit - mmap_min_addr)
+       if (len > mm->task_size - mmap_min_addr)
                return -ENOMEM;
 
        if (flags & MAP_FIXED)
@@ -153,7 +153,7 @@ radix__arch_get_unmapped_area_topdown(struct file *filp,
        if (addr) {
                addr = PAGE_ALIGN(addr);
                vma = find_vma(mm, addr);
-               if (mm->context.addr_limit - len >= addr && addr >= mmap_min_addr &&
+               if (mm->task_size - len >= addr && addr >= mmap_min_addr &&
                                (!vma || addr + len <= vma->vm_start))
                        return addr;
        }
index 251b6bae7023a8c159a01e5bf7678ebe0a252a82..ade66c3ecdcedb96ee06c2961076b6d1ea1e318b 100644 (file)
@@ -292,8 +292,8 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
                 * Check if we need to reduce the range, or if we can
                 * extend it to cover the next available slice.
                 */
-               if (addr >= mm->context.addr_limit)
-                       addr = mm->context.addr_limit;
+               if (addr >= high_limit)
+                       addr = high_limit;
                else if (slice_scan_available(addr, available, 1, &next_end)) {
                        addr = next_end;
                        goto next_slice;
index a409f78d206bf47936a366ee05540441474e2342..e94fbd4c88458aa5953a271b1ef1eac0ef5c5c66 100644 (file)
@@ -197,8 +197,8 @@ long sys_subpage_prot(unsigned long addr, unsigned long len, u32 __user *map)
 
        /* Check parameters */
        if ((addr & ~PAGE_MASK) || (len & ~PAGE_MASK) ||
-           addr >= mm->context.addr_limit || len >= mm->context.addr_limit ||
-           addr + len > mm->context.addr_limit)
+           addr >= mm->task_size || len >= mm->task_size ||
+           addr + len > mm->task_size)
                return -EINVAL;
 
        if (is_hugepage_only_range(mm, addr, len))