]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.4.96/mm-memory-failure.c-don-t-let-collect_procs-skip-over-processes-for-mf_action_required.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / releases / 3.4.96 / mm-memory-failure.c-don-t-let-collect_procs-skip-over-processes-for-mf_action_required.patch
1 From 74614de17db6fb472370c426d4f934d8d616edf2 Mon Sep 17 00:00:00 2001
2 From: Tony Luck <tony.luck@intel.com>
3 Date: Wed, 4 Jun 2014 16:11:01 -0700
4 Subject: mm/memory-failure.c: don't let collect_procs() skip over processes for MF_ACTION_REQUIRED
5
6 From: Tony Luck <tony.luck@intel.com>
7
8 commit 74614de17db6fb472370c426d4f934d8d616edf2 upstream.
9
10 When Linux sees an "action optional" machine check (where h/w has reported
11 an error that is not in the current execution path) we generally do not
12 want to signal a process, since most processes do not have a SIGBUS
13 handler - we'd just prematurely terminate the process for a problem that
14 they might never actually see.
15
16 task_early_kill() decides whether to consider a process - and it checks
17 whether this specific process has been marked for early signals with
18 "prctl", or if the system administrator has requested early signals for
19 all processes using /proc/sys/vm/memory_failure_early_kill.
20
21 But for MF_ACTION_REQUIRED case we must not defer. The error is in the
22 execution path of the current thread so we must send the SIGBUS
23 immediatley.
24
25 Fix by passing a flag argument through collect_procs*() to
26 task_early_kill() so it knows whether we can defer or must take action.
27
28 Signed-off-by: Tony Luck <tony.luck@intel.com>
29 Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
30 Cc: Andi Kleen <andi@firstfloor.org>
31 Cc: Borislav Petkov <bp@suse.de>
32 Cc: Chen Gong <gong.chen@linux.jf.intel.com>
33 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
34 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
35 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36
37 ---
38 mm/memory-failure.c | 21 ++++++++++++---------
39 1 file changed, 12 insertions(+), 9 deletions(-)
40
41 --- a/mm/memory-failure.c
42 +++ b/mm/memory-failure.c
43 @@ -382,10 +382,12 @@ static void kill_procs(struct list_head
44 }
45 }
46
47 -static int task_early_kill(struct task_struct *tsk)
48 +static int task_early_kill(struct task_struct *tsk, int force_early)
49 {
50 if (!tsk->mm)
51 return 0;
52 + if (force_early)
53 + return 1;
54 if (tsk->flags & PF_MCE_PROCESS)
55 return !!(tsk->flags & PF_MCE_EARLY);
56 return sysctl_memory_failure_early_kill;
57 @@ -395,7 +397,7 @@ static int task_early_kill(struct task_s
58 * Collect processes when the error hit an anonymous page.
59 */
60 static void collect_procs_anon(struct page *page, struct list_head *to_kill,
61 - struct to_kill **tkc)
62 + struct to_kill **tkc, int force_early)
63 {
64 struct vm_area_struct *vma;
65 struct task_struct *tsk;
66 @@ -409,7 +411,7 @@ static void collect_procs_anon(struct pa
67 for_each_process (tsk) {
68 struct anon_vma_chain *vmac;
69
70 - if (!task_early_kill(tsk))
71 + if (!task_early_kill(tsk, force_early))
72 continue;
73 list_for_each_entry(vmac, &av->head, same_anon_vma) {
74 vma = vmac->vma;
75 @@ -427,7 +429,7 @@ static void collect_procs_anon(struct pa
76 * Collect processes when the error hit a file mapped page.
77 */
78 static void collect_procs_file(struct page *page, struct list_head *to_kill,
79 - struct to_kill **tkc)
80 + struct to_kill **tkc, int force_early)
81 {
82 struct vm_area_struct *vma;
83 struct task_struct *tsk;
84 @@ -439,7 +441,7 @@ static void collect_procs_file(struct pa
85 for_each_process(tsk) {
86 pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT);
87
88 - if (!task_early_kill(tsk))
89 + if (!task_early_kill(tsk, force_early))
90 continue;
91
92 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff,
93 @@ -465,7 +467,8 @@ static void collect_procs_file(struct pa
94 * First preallocate one tokill structure outside the spin locks,
95 * so that we can kill at least one process reasonably reliable.
96 */
97 -static void collect_procs(struct page *page, struct list_head *tokill)
98 +static void collect_procs(struct page *page, struct list_head *tokill,
99 + int force_early)
100 {
101 struct to_kill *tk;
102
103 @@ -476,9 +479,9 @@ static void collect_procs(struct page *p
104 if (!tk)
105 return;
106 if (PageAnon(page))
107 - collect_procs_anon(page, tokill, &tk);
108 + collect_procs_anon(page, tokill, &tk, force_early);
109 else
110 - collect_procs_file(page, tokill, &tk);
111 + collect_procs_file(page, tokill, &tk, force_early);
112 kfree(tk);
113 }
114
115 @@ -948,7 +951,7 @@ static int hwpoison_user_mappings(struct
116 * there's nothing that can be done.
117 */
118 if (kill)
119 - collect_procs(ppage, &tokill);
120 + collect_procs(ppage, &tokill, flags & MF_ACTION_REQUIRED);
121
122 if (hpage != ppage)
123 lock_page(ppage);