diff options
-rw-r--r-- | arch/powerpc/include/asm/mmu_context.h | 1 | ||||
-rw-r--r-- | arch/um/include/asm/mmu_context.h | 1 | ||||
-rw-r--r-- | arch/unicore32/include/asm/mmu_context.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/mmu_context.h | 6 | ||||
-rw-r--r-- | arch/x86/include/asm/mpx.h | 15 | ||||
-rw-r--r-- | arch/x86/mm/mpx.c | 10 | ||||
-rw-r--r-- | include/asm-generic/mm_hooks.h | 1 | ||||
-rw-r--r-- | mm/mmap.c | 15 | ||||
-rw-r--r-- | tools/objtool/Makefile | 3 |
9 files changed, 27 insertions, 26 deletions
diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h index 611204e588b9..58efca934311 100644 --- a/arch/powerpc/include/asm/mmu_context.h +++ b/arch/powerpc/include/asm/mmu_context.h | |||
@@ -232,7 +232,6 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, | |||
232 | extern void arch_exit_mmap(struct mm_struct *mm); | 232 | extern void arch_exit_mmap(struct mm_struct *mm); |
233 | 233 | ||
234 | static inline void arch_unmap(struct mm_struct *mm, | 234 | static inline void arch_unmap(struct mm_struct *mm, |
235 | struct vm_area_struct *vma, | ||
236 | unsigned long start, unsigned long end) | 235 | unsigned long start, unsigned long end) |
237 | { | 236 | { |
238 | if (start <= mm->context.vdso_base && mm->context.vdso_base < end) | 237 | if (start <= mm->context.vdso_base && mm->context.vdso_base < end) |
diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h index fca34b2177e2..9f4b4bb78120 100644 --- a/arch/um/include/asm/mmu_context.h +++ b/arch/um/include/asm/mmu_context.h | |||
@@ -22,7 +22,6 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) | |||
22 | } | 22 | } |
23 | extern void arch_exit_mmap(struct mm_struct *mm); | 23 | extern void arch_exit_mmap(struct mm_struct *mm); |
24 | static inline void arch_unmap(struct mm_struct *mm, | 24 | static inline void arch_unmap(struct mm_struct *mm, |
25 | struct vm_area_struct *vma, | ||
26 | unsigned long start, unsigned long end) | 25 | unsigned long start, unsigned long end) |
27 | { | 26 | { |
28 | } | 27 | } |
diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h index 5c205a9cb5a6..9f06ea5466dd 100644 --- a/arch/unicore32/include/asm/mmu_context.h +++ b/arch/unicore32/include/asm/mmu_context.h | |||
@@ -88,7 +88,6 @@ static inline int arch_dup_mmap(struct mm_struct *oldmm, | |||
88 | } | 88 | } |
89 | 89 | ||
90 | static inline void arch_unmap(struct mm_struct *mm, | 90 | static inline void arch_unmap(struct mm_struct *mm, |
91 | struct vm_area_struct *vma, | ||
92 | unsigned long start, unsigned long end) | 91 | unsigned long start, unsigned long end) |
93 | { | 92 | { |
94 | } | 93 | } |
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 93dff1963337..9024236693d2 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h | |||
@@ -278,8 +278,8 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, | |||
278 | mpx_mm_init(mm); | 278 | mpx_mm_init(mm); |
279 | } | 279 | } |
280 | 280 | ||
281 | static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | 281 | static inline void arch_unmap(struct mm_struct *mm, unsigned long start, |
282 | unsigned long start, unsigned long end) | 282 | unsigned long end) |
283 | { | 283 | { |
284 | /* | 284 | /* |
285 | * mpx_notify_unmap() goes and reads a rarely-hot | 285 | * mpx_notify_unmap() goes and reads a rarely-hot |
@@ -299,7 +299,7 @@ static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | |||
299 | * consistently wrong. | 299 | * consistently wrong. |
300 | */ | 300 | */ |
301 | if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX))) | 301 | if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX))) |
302 | mpx_notify_unmap(mm, vma, start, end); | 302 | mpx_notify_unmap(mm, start, end); |
303 | } | 303 | } |
304 | 304 | ||
305 | /* | 305 | /* |
diff --git a/arch/x86/include/asm/mpx.h b/arch/x86/include/asm/mpx.h index d0b1434fb0b6..143a5c193ed3 100644 --- a/arch/x86/include/asm/mpx.h +++ b/arch/x86/include/asm/mpx.h | |||
@@ -64,12 +64,15 @@ struct mpx_fault_info { | |||
64 | }; | 64 | }; |
65 | 65 | ||
66 | #ifdef CONFIG_X86_INTEL_MPX | 66 | #ifdef CONFIG_X86_INTEL_MPX |
67 | int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs); | 67 | |
68 | int mpx_handle_bd_fault(void); | 68 | extern int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs); |
69 | extern int mpx_handle_bd_fault(void); | ||
70 | |||
69 | static inline int kernel_managing_mpx_tables(struct mm_struct *mm) | 71 | static inline int kernel_managing_mpx_tables(struct mm_struct *mm) |
70 | { | 72 | { |
71 | return (mm->context.bd_addr != MPX_INVALID_BOUNDS_DIR); | 73 | return (mm->context.bd_addr != MPX_INVALID_BOUNDS_DIR); |
72 | } | 74 | } |
75 | |||
73 | static inline void mpx_mm_init(struct mm_struct *mm) | 76 | static inline void mpx_mm_init(struct mm_struct *mm) |
74 | { | 77 | { |
75 | /* | 78 | /* |
@@ -78,11 +81,10 @@ static inline void mpx_mm_init(struct mm_struct *mm) | |||
78 | */ | 81 | */ |
79 | mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR; | 82 | mm->context.bd_addr = MPX_INVALID_BOUNDS_DIR; |
80 | } | 83 | } |
81 | void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | ||
82 | unsigned long start, unsigned long end); | ||
83 | 84 | ||
84 | unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, | 85 | extern void mpx_notify_unmap(struct mm_struct *mm, unsigned long start, unsigned long end); |
85 | unsigned long flags); | 86 | extern unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, unsigned long flags); |
87 | |||
86 | #else | 88 | #else |
87 | static inline int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs) | 89 | static inline int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs) |
88 | { | 90 | { |
@@ -100,7 +102,6 @@ static inline void mpx_mm_init(struct mm_struct *mm) | |||
100 | { | 102 | { |
101 | } | 103 | } |
102 | static inline void mpx_notify_unmap(struct mm_struct *mm, | 104 | static inline void mpx_notify_unmap(struct mm_struct *mm, |
103 | struct vm_area_struct *vma, | ||
104 | unsigned long start, unsigned long end) | 105 | unsigned long start, unsigned long end) |
105 | { | 106 | { |
106 | } | 107 | } |
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c index 59726aaf4671..0d1c47cbbdd6 100644 --- a/arch/x86/mm/mpx.c +++ b/arch/x86/mm/mpx.c | |||
@@ -881,9 +881,10 @@ static int mpx_unmap_tables(struct mm_struct *mm, | |||
881 | * the virtual address region start...end have already been split if | 881 | * the virtual address region start...end have already been split if |
882 | * necessary, and the 'vma' is the first vma in this range (start -> end). | 882 | * necessary, and the 'vma' is the first vma in this range (start -> end). |
883 | */ | 883 | */ |
884 | void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | 884 | void mpx_notify_unmap(struct mm_struct *mm, unsigned long start, |
885 | unsigned long start, unsigned long end) | 885 | unsigned long end) |
886 | { | 886 | { |
887 | struct vm_area_struct *vma; | ||
887 | int ret; | 888 | int ret; |
888 | 889 | ||
889 | /* | 890 | /* |
@@ -902,11 +903,12 @@ void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | |||
902 | * which should not occur normally. Being strict about it here | 903 | * which should not occur normally. Being strict about it here |
903 | * helps ensure that we do not have an exploitable stack overflow. | 904 | * helps ensure that we do not have an exploitable stack overflow. |
904 | */ | 905 | */ |
905 | do { | 906 | vma = find_vma(mm, start); |
907 | while (vma && vma->vm_start < end) { | ||
906 | if (vma->vm_flags & VM_MPX) | 908 | if (vma->vm_flags & VM_MPX) |
907 | return; | 909 | return; |
908 | vma = vma->vm_next; | 910 | vma = vma->vm_next; |
909 | } while (vma && vma->vm_start < end); | 911 | } |
910 | 912 | ||
911 | ret = mpx_unmap_tables(mm, start, end); | 913 | ret = mpx_unmap_tables(mm, start, end); |
912 | if (ret) | 914 | if (ret) |
diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h index 8ac4e68a12f0..6736ed2f632b 100644 --- a/include/asm-generic/mm_hooks.h +++ b/include/asm-generic/mm_hooks.h | |||
@@ -18,7 +18,6 @@ static inline void arch_exit_mmap(struct mm_struct *mm) | |||
18 | } | 18 | } |
19 | 19 | ||
20 | static inline void arch_unmap(struct mm_struct *mm, | 20 | static inline void arch_unmap(struct mm_struct *mm, |
21 | struct vm_area_struct *vma, | ||
22 | unsigned long start, unsigned long end) | 21 | unsigned long start, unsigned long end) |
23 | { | 22 | { |
24 | } | 23 | } |
@@ -2735,9 +2735,17 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len, | |||
2735 | return -EINVAL; | 2735 | return -EINVAL; |
2736 | 2736 | ||
2737 | len = PAGE_ALIGN(len); | 2737 | len = PAGE_ALIGN(len); |
2738 | end = start + len; | ||
2738 | if (len == 0) | 2739 | if (len == 0) |
2739 | return -EINVAL; | 2740 | return -EINVAL; |
2740 | 2741 | ||
2742 | /* | ||
2743 | * arch_unmap() might do unmaps itself. It must be called | ||
2744 | * and finish any rbtree manipulation before this code | ||
2745 | * runs and also starts to manipulate the rbtree. | ||
2746 | */ | ||
2747 | arch_unmap(mm, start, end); | ||
2748 | |||
2741 | /* Find the first overlapping VMA */ | 2749 | /* Find the first overlapping VMA */ |
2742 | vma = find_vma(mm, start); | 2750 | vma = find_vma(mm, start); |
2743 | if (!vma) | 2751 | if (!vma) |
@@ -2746,7 +2754,6 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len, | |||
2746 | /* we have start < vma->vm_end */ | 2754 | /* we have start < vma->vm_end */ |
2747 | 2755 | ||
2748 | /* if it doesn't overlap, we have nothing.. */ | 2756 | /* if it doesn't overlap, we have nothing.. */ |
2749 | end = start + len; | ||
2750 | if (vma->vm_start >= end) | 2757 | if (vma->vm_start >= end) |
2751 | return 0; | 2758 | return 0; |
2752 | 2759 | ||
@@ -2816,12 +2823,6 @@ int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len, | |||
2816 | /* Detach vmas from rbtree */ | 2823 | /* Detach vmas from rbtree */ |
2817 | detach_vmas_to_be_unmapped(mm, vma, prev, end); | 2824 | detach_vmas_to_be_unmapped(mm, vma, prev, end); |
2818 | 2825 | ||
2819 | /* | ||
2820 | * mpx unmap needs to be called with mmap_sem held for write. | ||
2821 | * It is safe to call it before unmap_region(). | ||
2822 | */ | ||
2823 | arch_unmap(mm, vma, start, end); | ||
2824 | |||
2825 | if (downgrade) | 2826 | if (downgrade) |
2826 | downgrade_write(&mm->mmap_sem); | 2827 | downgrade_write(&mm->mmap_sem); |
2827 | 2828 | ||
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 53f8be0f4a1f..88158239622b 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile | |||
@@ -7,11 +7,12 @@ ARCH := x86 | |||
7 | endif | 7 | endif |
8 | 8 | ||
9 | # always use the host compiler | 9 | # always use the host compiler |
10 | HOSTAR ?= ar | ||
10 | HOSTCC ?= gcc | 11 | HOSTCC ?= gcc |
11 | HOSTLD ?= ld | 12 | HOSTLD ?= ld |
13 | AR = $(HOSTAR) | ||
12 | CC = $(HOSTCC) | 14 | CC = $(HOSTCC) |
13 | LD = $(HOSTLD) | 15 | LD = $(HOSTLD) |
14 | AR = ar | ||
15 | 16 | ||
16 | ifeq ($(srctree),) | 17 | ifeq ($(srctree),) |
17 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) | 18 | srctree := $(patsubst %/,%,$(dir $(CURDIR))) |