From c8e2a4372dadb3a672738e84b0ab0254307e0269 Mon Sep 17 00:00:00 2001 From: Yang Yingliang Date: Fri, 15 Nov 2019 21:45:22 +0800 Subject: [PATCH] Revert "mm: Add a flag MAP_VA32BIT for mmap" ascend inclusion category: bugfix bugzilla: NA CVE: NA ------------ It's specific code for ascend, so remove it. This reverts commit 25cf3abca447947a56e74ee9393943e9a3adf8a8. Signed-off-by: Yang Yingliang --- arch/arm64/include/asm/processor.h | 2 -- fs/hugetlbfs/inode.c | 7 ----- include/linux/mm.h | 23 -------------- include/uapi/asm-generic/mman.h | 1 - mm/mmap.c | 49 ------------------------------ 5 files changed, 82 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 9ef94ed45311..6e0083f26b4f 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -70,8 +70,6 @@ #define TASK_SIZE TASK_SIZE_64 #endif /* CONFIG_COMPAT */ -#define MMAP_TOP_4G_SIZE (0x100000000UL) - #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 4)) #define STACK_TOP_MAX TASK_SIZE_64 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 42ea465ed9d0..2c75dc4b0b85 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -215,10 +215,6 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, if (addr) { addr = ALIGN(addr, huge_page_size(h)); - - if (!mmap_va32bit_check(addr, len, flags)) - return -ENOMEM; - vma = find_vma(mm, addr); if (TASK_SIZE - len >= addr && (!vma || addr + len <= vm_start_gap(vma))) @@ -231,9 +227,6 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, info.high_limit = TASK_SIZE; info.align_mask = PAGE_MASK & ~huge_page_mask(h); info.align_offset = 0; - - mmap_va32bit_set_limit(&info, flags); - return vm_unmapped_area(&info); } #endif diff --git a/include/linux/mm.h b/include/linux/mm.h index 65f6919675d9..65d91b1fc6b2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2355,29 +2355,6 @@ struct vm_unmapped_area_info { unsigned long align_offset; }; - -#ifdef CONFIG_ARCH_ASCEND - -extern int mmap_va32bit_check(unsigned long addr, unsigned long len, - unsigned long flags); -extern void mmap_va32bit_set_limit(struct vm_unmapped_area_info *info, - unsigned long flags); - -#else - -static inline int mmap_va32bit_check(unsigned long addr, unsigned long len, - unsigned long flags) -{ - return 1; -} - -static inline void mmap_va32bit_set_limit(struct vm_unmapped_area_info *info, - unsigned long flags) -{ -} - -#endif - extern unsigned long unmapped_area(struct vm_unmapped_area_info *info); extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info); diff --git a/include/uapi/asm-generic/mman.h b/include/uapi/asm-generic/mman.h index 84ae839fe7d1..653687d9771b 100644 --- a/include/uapi/asm-generic/mman.h +++ b/include/uapi/asm-generic/mman.h @@ -14,7 +14,6 @@ #define MAP_STACK 0x20000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x40000 /* create a huge page mapping */ #define MAP_SYNC 0x80000 /* perform synchronous page faults for the mapping */ -#define MAP_VA32BIT 0x0200 /* Bits [26:31] are reserved, see mman-common.h for MAP_HUGETLB usage */ diff --git a/mm/mmap.c b/mm/mmap.c index 2eeee2f9845e..0a260e102b24 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1841,38 +1841,6 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return error; } -#ifdef CONFIG_ARCH_ASCEND - -int mmap_va32bit_check(unsigned long addr, unsigned long len, - unsigned long flags) -{ - return !(!(flags & MAP_VA32BIT) && - ((addr + len) > (TASK_SIZE - MMAP_TOP_4G_SIZE)) && - (addr < TASK_SIZE)); -} - - -void mmap_va32bit_set_limit(struct vm_unmapped_area_info *info, - unsigned long flags) -{ - const unsigned long high_limit = TASK_SIZE; - const unsigned long divide = TASK_SIZE - MMAP_TOP_4G_SIZE; - - if (info == NULL) - return; - - if (flags & MAP_VA32BIT) { - info->low_limit = divide; - info->high_limit = high_limit; - } else { - /* low_limit do not need set */ - if (info->high_limit > divide) - info->high_limit = divide; - } -} - -#endif - unsigned long unmapped_area(struct vm_unmapped_area_info *info) { /* @@ -2103,10 +2071,6 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, if (addr) { addr = PAGE_ALIGN(addr); - - if (!mmap_va32bit_check(addr, len, flags)) - return -ENOMEM; - vma = find_vma_prev(mm, addr, &prev); if (TASK_SIZE - len >= addr && addr >= mmap_min_addr && (!vma || addr + len <= vm_start_gap(vma)) && @@ -2119,9 +2083,6 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.low_limit = mm->mmap_base; info.high_limit = TASK_SIZE; info.align_mask = 0; - - mmap_va32bit_set_limit(&info, flags); - return vm_unmapped_area(&info); } #endif @@ -2151,10 +2112,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, /* requesting a specific address */ if (addr) { addr = PAGE_ALIGN(addr); - - if (!mmap_va32bit_check(addr, len, flags)) - return -ENOMEM; - vma = find_vma_prev(mm, addr, &prev); if (TASK_SIZE - len >= addr && addr >= mmap_min_addr && (!vma || addr + len <= vm_start_gap(vma)) && @@ -2167,9 +2124,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.low_limit = max(PAGE_SIZE, mmap_min_addr); info.high_limit = mm->mmap_base; info.align_mask = 0; - - mmap_va32bit_set_limit(&info, flags); - addr = vm_unmapped_area(&info); /* @@ -2183,9 +2137,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, info.flags = 0; info.low_limit = TASK_UNMAPPED_BASE; info.high_limit = TASK_SIZE; - - mmap_va32bit_set_limit(&info, flags); - addr = vm_unmapped_area(&info); } -- GitLab