aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/mmu_context.h6
-rw-r--r--arch/x86/include/asm/mpx.h15
-rw-r--r--arch/x86/mm/mpx.c10
3 files changed, 17 insertions, 14 deletions
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
281static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, 281static 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
67int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs); 67
68int mpx_handle_bd_fault(void); 68extern int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs);
69extern int mpx_handle_bd_fault(void);
70
69static inline int kernel_managing_mpx_tables(struct mm_struct *mm) 71static 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
73static inline void mpx_mm_init(struct mm_struct *mm) 76static 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}
81void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
82 unsigned long start, unsigned long end);
83 84
84unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, 85extern void mpx_notify_unmap(struct mm_struct *mm, unsigned long start, unsigned long end);
85 unsigned long flags); 86extern unsigned long mpx_unmapped_area_check(unsigned long addr, unsigned long len, unsigned long flags);
87
86#else 88#else
87static inline int mpx_fault_info(struct mpx_fault_info *info, struct pt_regs *regs) 89static 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}
102static inline void mpx_notify_unmap(struct mm_struct *mm, 104static 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 */
884void mpx_notify_unmap(struct mm_struct *mm, struct vm_area_struct *vma, 884void 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)