diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-22 12:39:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-22 12:39:10 -0400 |
commit | 86c5bf7101991608483c93e7954b93acdc85ea57 (patch) | |
tree | c66010150a6cc66df6ab0339f08cee3d623d78c7 /fs/proc | |
parent | bfb7bfef6f9e8f113b892070fd622ae1c52e676b (diff) | |
parent | d17af5056cf9e9fc05e68832f7c15687fcc12281 (diff) |
Merge branch 'mm-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull vmap stack fixes from Ingo Molnar:
"This is fallout from CONFIG_HAVE_ARCH_VMAP_STACK=y on x86: stack
accesses that used to be just somewhat questionable are now totally
buggy.
These changes try to do it without breaking the ABI: the fields are
left there, they are just reporting zero, or reporting narrower
information (the maps file change)"
* 'mm-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
mm: Change vm_is_stack_for_task() to vm_is_stack_for_current()
fs/proc: Stop trying to report thread stacks
fs/proc: Stop reporting eip and esp in /proc/PID/stat
mm/numa: Remove duplicated include from mprotect.c
Diffstat (limited to 'fs/proc')
-rw-r--r-- | fs/proc/array.c | 9 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 29 | ||||
-rw-r--r-- | fs/proc/task_nommu.c | 28 |
3 files changed, 25 insertions, 41 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index 89600fd5963d..81818adb8e9e 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -412,10 +412,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
412 | mm = get_task_mm(task); | 412 | mm = get_task_mm(task); |
413 | if (mm) { | 413 | if (mm) { |
414 | vsize = task_vsize(mm); | 414 | vsize = task_vsize(mm); |
415 | if (permitted) { | 415 | /* |
416 | eip = KSTK_EIP(task); | 416 | * esp and eip are intentionally zeroed out. There is no |
417 | esp = KSTK_ESP(task); | 417 | * non-racy way to read them without freezing the task. |
418 | } | 418 | * Programs that need reliable values can use ptrace(2). |
419 | */ | ||
419 | } | 420 | } |
420 | 421 | ||
421 | get_task_comm(tcomm, task); | 422 | get_task_comm(tcomm, task); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6909582ce5e5..35b92d81692f 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -266,24 +266,15 @@ static int do_maps_open(struct inode *inode, struct file *file, | |||
266 | * /proc/PID/maps that is the stack of the main task. | 266 | * /proc/PID/maps that is the stack of the main task. |
267 | */ | 267 | */ |
268 | static int is_stack(struct proc_maps_private *priv, | 268 | static int is_stack(struct proc_maps_private *priv, |
269 | struct vm_area_struct *vma, int is_pid) | 269 | struct vm_area_struct *vma) |
270 | { | 270 | { |
271 | int stack = 0; | 271 | /* |
272 | 272 | * We make no effort to guess what a given thread considers to be | |
273 | if (is_pid) { | 273 | * its "stack". It's not even well-defined for programs written |
274 | stack = vma->vm_start <= vma->vm_mm->start_stack && | 274 | * languages like Go. |
275 | vma->vm_end >= vma->vm_mm->start_stack; | 275 | */ |
276 | } else { | 276 | return vma->vm_start <= vma->vm_mm->start_stack && |
277 | struct inode *inode = priv->inode; | 277 | vma->vm_end >= vma->vm_mm->start_stack; |
278 | struct task_struct *task; | ||
279 | |||
280 | rcu_read_lock(); | ||
281 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | ||
282 | if (task) | ||
283 | stack = vma_is_stack_for_task(vma, task); | ||
284 | rcu_read_unlock(); | ||
285 | } | ||
286 | return stack; | ||
287 | } | 278 | } |
288 | 279 | ||
289 | static void | 280 | static void |
@@ -354,7 +345,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) | |||
354 | goto done; | 345 | goto done; |
355 | } | 346 | } |
356 | 347 | ||
357 | if (is_stack(priv, vma, is_pid)) | 348 | if (is_stack(priv, vma)) |
358 | name = "[stack]"; | 349 | name = "[stack]"; |
359 | } | 350 | } |
360 | 351 | ||
@@ -1669,7 +1660,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) | |||
1669 | seq_file_path(m, file, "\n\t= "); | 1660 | seq_file_path(m, file, "\n\t= "); |
1670 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { | 1661 | } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { |
1671 | seq_puts(m, " heap"); | 1662 | seq_puts(m, " heap"); |
1672 | } else if (is_stack(proc_priv, vma, is_pid)) { | 1663 | } else if (is_stack(proc_priv, vma)) { |
1673 | seq_puts(m, " stack"); | 1664 | seq_puts(m, " stack"); |
1674 | } | 1665 | } |
1675 | 1666 | ||
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index faacb0c0d857..37175621e890 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -124,25 +124,17 @@ unsigned long task_statm(struct mm_struct *mm, | |||
124 | } | 124 | } |
125 | 125 | ||
126 | static int is_stack(struct proc_maps_private *priv, | 126 | static int is_stack(struct proc_maps_private *priv, |
127 | struct vm_area_struct *vma, int is_pid) | 127 | struct vm_area_struct *vma) |
128 | { | 128 | { |
129 | struct mm_struct *mm = vma->vm_mm; | 129 | struct mm_struct *mm = vma->vm_mm; |
130 | int stack = 0; | 130 | |
131 | 131 | /* | |
132 | if (is_pid) { | 132 | * We make no effort to guess what a given thread considers to be |
133 | stack = vma->vm_start <= mm->start_stack && | 133 | * its "stack". It's not even well-defined for programs written |
134 | vma->vm_end >= mm->start_stack; | 134 | * languages like Go. |
135 | } else { | 135 | */ |
136 | struct inode *inode = priv->inode; | 136 | return vma->vm_start <= mm->start_stack && |
137 | struct task_struct *task; | 137 | vma->vm_end >= mm->start_stack; |
138 | |||
139 | rcu_read_lock(); | ||
140 | task = pid_task(proc_pid(inode), PIDTYPE_PID); | ||
141 | if (task) | ||
142 | stack = vma_is_stack_for_task(vma, task); | ||
143 | rcu_read_unlock(); | ||
144 | } | ||
145 | return stack; | ||
146 | } | 138 | } |
147 | 139 | ||
148 | /* | 140 | /* |
@@ -184,7 +176,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, | |||
184 | if (file) { | 176 | if (file) { |
185 | seq_pad(m, ' '); | 177 | seq_pad(m, ' '); |
186 | seq_file_path(m, file, ""); | 178 | seq_file_path(m, file, ""); |
187 | } else if (mm && is_stack(priv, vma, is_pid)) { | 179 | } else if (mm && is_stack(priv, vma)) { |
188 | seq_pad(m, ' '); | 180 | seq_pad(m, ' '); |
189 | seq_printf(m, "[stack]"); | 181 | seq_printf(m, "[stack]"); |
190 | } | 182 | } |