Patch "powerpc/64s/radix: Fix 128TB-512TB virtual address boundary case allocation" has been added to the 4.14-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
powerpc/64s/radix: Fix 128TB-512TB virtual address boundary case allocation
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
powerpc-64s-radix-fix-128tb-512tb-virtual-address-boundary-case-allocation.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
85e3f1adcb9d49300b0a943bb93f9604be375bfbMon Sep 17 00:00:00 2001
From: Nicholas Piggin <[email protected]>
Date: Fri, 10 Nov 2017 04:27:39 +1100
Subject: powerpc/64s/radix: Fix 128TB-512TB virtual address boundary case allocation
From: Nicholas Piggin <[email protected]>
commit 85e3f1adcb9d49300b0a943bb93f9604be375bfb upstream.
Radix VA space allocations test addresses against mm->task_size which is 512TB, even in cases where the intention is to limit allocation to below 128TB.
This results in mmap with a hint address below 128TB but address + length above 128TB succeeding when it should fail (as hash does after the previous patch).
Set the high address limit to be considered up front, and base subsequent allocation checks on that consistently.
--- arch/powerpc/mm/hugetlbpage-radix.c | 26 +++++++++++------ arch/powerpc/mm/mmap.c | 55 +++++++++++++++++++++--------------- 2 files changed, 50 insertions(+), 31 deletions(-)
arch/powerpc/mm/hugetlbpage-radix.c +17 -9
@@ -49,17 +49,28 @@ radix__hugetlb_get_unmapped_area(structstruct mm_struct *mm = current->mm;struct vm_area_struct *vma;struct hstate *h =hstate_file (file); +int fixed = (flags &MAP_FIXED ); +unsigned long high_limit;struct vm_unmapped_area_info info; -if (unlikely (addr > mm->context.addr_limit && addr <TASK_SIZE )) - mm->context.addr_limit =TASK_SIZE ; + high_limit =DEFAULT_MAP_WINDOW ; +if (addr >= high_limit || (fixed && (addr + len > high_limit))) + high_limit =TASK_SIZE ;if (len & ~huge_page_mask (h))return -EINVAL ; -if (len > mm->task_size) +if (len > high_limit)return -ENOMEM ; +if (fixed) { +if (addr > high_limit - len) +return -ENOMEM ; + } -if (flags &MAP_FIXED ) { +if (unlikely (addr > mm->context.addr_limit && + mm->context.addr_limit !=TASK_SIZE )) + mm->context.addr_limit =TASK_SIZE ; + +if (fixed) {if (prepare_hugepage_range (file, addr, len))return -EINVAL ;return addr;
@@ -68,7 +79,7 @@ radix__hugetlb_get_unmapped_area(structif (addr) { addr =ALIGN (addr,huge_page_size (h)); vma =find_vma (mm, addr); -if (mm->task_size - len >= addr && +if (high_limit - len >= addr && (!vma || addr + len <=vm_start_gap (vma)))return addr; }
@@ -79,12 +90,9 @@ radix__hugetlb_get_unmapped_area(struct info.flags =VM_UNMAPPED_AREA_TOPDOWN ; info.length = len; info.low_limit =PAGE_SIZE ; - info.high_limit = current->mm->mmap_base; + info.high_limit = mm->mmap_base + (high_limit -DEFAULT_MAP_WINDOW ); info.align_mask =PAGE_MASK & ~huge_page_mask (h); info.align_offset =0 ; -if (addr >DEFAULT_MAP_WINDOW ) - info.high_limit += mm->context.addr_limit -DEFAULT_MAP_WINDOW ; -return vm_unmapped_area (&info); }
arch/powerpc/mm/mmap.c +33 -22
105 lines not on this page · raw message
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/powerpc-64s-hash-fix-128tb-512tb-virtual-address-boundary-case-allocation.patch queue-4.14/powerpc-64s-hash-fix-fork-with-512tb-process-address-space.patch queue-4.14/powerpc-64s-radix-fix-128tb-512tb-virtual-address-boundary-case-allocation.patch queue-4.14/powerpc-64s-hash-allow-map_fixed-allocations-to-cross-128tb-boundary.patch queue-4.14/powerpc-64s-hash-fix-512t-hint-detection-to-use-128t.patch