]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0063-ARM-Initialize-split-page-table-locks-for-vector-pag.patch
Fix memguard and related syscalls
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0063-ARM-Initialize-split-page-table-locks-for-vector-pag.patch
1 From 9ce14e569bf60237f5962e264e049bda37dcebf2 Mon Sep 17 00:00:00 2001
2 From: Frank Rowand <frank.rowand@am.sony.com>
3 Date: Sat, 1 Oct 2011 18:58:13 -0700
4 Subject: [PATCH 063/366] ARM: Initialize split page table locks for vector
5  page
6
7 Without this patch, ARM can not use SPLIT_PTLOCK_CPUS if
8 PREEMPT_RT_FULL=y because vectors_user_mapping() creates a
9 VM_ALWAYSDUMP mapping of the vector page (address 0xffff0000), but no
10 ptl->lock has been allocated for the page.  An attempt to coredump
11 that page will result in a kernel NULL pointer dereference when
12 follow_page() attempts to lock the page.
13
14 The call tree to the NULL pointer dereference is:
15
16    do_notify_resume()
17       get_signal_to_deliver()
18          do_coredump()
19             elf_core_dump()
20                get_dump_page()
21                   __get_user_pages()
22                      follow_page()
23                         pte_offset_map_lock() <----- a #define
24                            ...
25                               rt_spin_lock()
26
27 The underlying problem is exposed by mm-shrink-the-page-frame-to-rt-size.patch.
28
29 Signed-off-by: Frank Rowand <frank.rowand@am.sony.com>
30 Cc: Frank <Frank_Rowand@sonyusa.com>
31 Cc: Peter Zijlstra <peterz@infradead.org>
32 Link: http://lkml.kernel.org/r/4E87C535.2030907@am.sony.com
33 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
34 ---
35  arch/arm/kernel/process.c | 24 ++++++++++++++++++++++++
36  1 file changed, 24 insertions(+)
37
38 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
39 index 0017b3e..0b670cf 100644
40 --- a/arch/arm/kernel/process.c
41 +++ b/arch/arm/kernel/process.c
42 @@ -394,6 +394,30 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
43  }
44  
45  #ifdef CONFIG_MMU
46 +/*
47 + * CONFIG_SPLIT_PTLOCK_CPUS results in a page->ptl lock.  If the lock is not
48 + * initialized by pgtable_page_ctor() then a coredump of the vector page will
49 + * fail.
50 + */
51 +static int __init vectors_user_mapping_init_page(void)
52 +{
53 +       struct page *page;
54 +       unsigned long addr = 0xffff0000;
55 +       pgd_t *pgd;
56 +       pud_t *pud;
57 +       pmd_t *pmd;
58 +
59 +       pgd = pgd_offset_k(addr);
60 +       pud = pud_offset(pgd, addr);
61 +       pmd = pmd_offset(pud, addr);
62 +       page = pmd_page(*(pmd));
63 +
64 +       pgtable_page_ctor(page);
65 +
66 +       return 0;
67 +}
68 +late_initcall(vectors_user_mapping_init_page);
69 +
70  #ifdef CONFIG_KUSER_HELPERS
71  /*
72   * The vectors page is always readable from user space for the
73 -- 
74 1.9.1
75