ARM: make vectors page inaccessible from userspace
authorRussell King <rmk+kernel@arm.linux.org.uk>
Wed, 31 Jul 2013 20:58:56 +0000 (21:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Aug 2013 01:35:20 +0000 (18:35 -0700)
commit a5463cd3435475386cbbe7b06e01292ac169d36f upstream.

If kuser helpers are not provided by the kernel, disable user access to
the vectors page.  With the kuser helpers gone, there is no reason for
this page to be visible to userspace.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/include/asm/page.h
arch/arm/kernel/process.c
arch/arm/mm/mmu.c

index 812a4944e78343469a2216327a746f37ce01b98c..cbdc7a21f869fcce44573119edb99c26d710c1a9 100644 (file)
@@ -142,7 +142,9 @@ extern void __cpu_copy_user_highpage(struct page *to, struct page *from,
 #define clear_page(page)       memset((void *)(page), 0, PAGE_SIZE)
 extern void copy_page(void *to, const void *from);
 
+#ifdef CONFIG_KUSER_HELPERS
 #define __HAVE_ARCH_GATE_AREA 1
+#endif
 
 #ifdef CONFIG_ARM_LPAE
 #include <asm/pgtable-3level-types.h>
index 72315e7be22be292cd7ed0d2b4bd0ef0110b5d19..1ed29cc2297913744c50fbed206a50face8e2e7c 100644 (file)
@@ -433,6 +433,7 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
 }
 
 #ifdef CONFIG_MMU
+#ifdef CONFIG_KUSER_HELPERS
 /*
  * The vectors page is always readable from user space for the
  * atomic helpers. Insert it into the gate_vma so that it is visible
@@ -465,10 +466,14 @@ int in_gate_area_no_mm(unsigned long addr)
 {
        return in_gate_area(NULL, addr);
 }
+#define is_gate_vma(vma)       ((vma) = &gate_vma)
+#else
+#define is_gate_vma(vma)       0
+#endif
 
 const char *arch_vma_name(struct vm_area_struct *vma)
 {
-       return (vma == &gate_vma) ? "[vectors]" :
+       return is_gate_vma(vma) ? "[vectors]" :
                (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
                 "[sigpage]" : NULL;
 }
index 08b37c421a5eed28e0da9a1e2e507824a528e2bc..daf336fe0be89250dc82343d81681ee746abc5d9 100644 (file)
@@ -1220,7 +1220,11 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
        map.pfn = __phys_to_pfn(virt_to_phys(vectors));
        map.virtual = 0xffff0000;
        map.length = PAGE_SIZE;
+#ifdef CONFIG_KUSER_HELPERS
        map.type = MT_HIGH_VECTORS;
+#else
+       map.type = MT_LOW_VECTORS;
+#endif
        create_mapping(&map);
 
        if (!vectors_high()) {