Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+29 -70
-26
Documentation/filesystems/proc.txt
··· 395 395 396 396 or if empty, the mapping is anonymous. 397 397 398 - The /proc/PID/task/TID/maps is a view of the virtual memory from the viewpoint 399 - of the individual tasks of a process. In this file you will see a mapping marked 400 - as [stack] if that task sees it as a stack. Hence, for the example above, the 401 - task-level map, i.e. /proc/PID/task/TID/maps for thread 1001 will look like this: 402 - 403 - 08048000-08049000 r-xp 00000000 03:00 8312 /opt/test 404 - 08049000-0804a000 rw-p 00001000 03:00 8312 /opt/test 405 - 0804a000-0806b000 rw-p 00000000 00:00 0 [heap] 406 - a7cb1000-a7cb2000 ---p 00000000 00:00 0 407 - a7cb2000-a7eb2000 rw-p 00000000 00:00 0 408 - a7eb2000-a7eb3000 ---p 00000000 00:00 0 409 - a7eb3000-a7ed5000 rw-p 00000000 00:00 0 [stack] 410 - a7ed5000-a8008000 r-xp 00000000 03:00 4222 /lib/libc.so.6 411 - a8008000-a800a000 r--p 00133000 03:00 4222 /lib/libc.so.6 412 - a800a000-a800b000 rw-p 00135000 03:00 4222 /lib/libc.so.6 413 - a800b000-a800e000 rw-p 00000000 00:00 0 414 - a800e000-a8022000 r-xp 00000000 03:00 14462 /lib/libpthread.so.0 415 - a8022000-a8023000 r--p 00013000 03:00 14462 /lib/libpthread.so.0 416 - a8023000-a8024000 rw-p 00014000 03:00 14462 /lib/libpthread.so.0 417 - a8024000-a8027000 rw-p 00000000 00:00 0 418 - a8027000-a8043000 r-xp 00000000 03:00 8317 /lib/ld-linux.so.2 419 - a8043000-a8044000 r--p 0001b000 03:00 8317 /lib/ld-linux.so.2 420 - a8044000-a8045000 rw-p 0001c000 03:00 8317 /lib/ld-linux.so.2 421 - aff35000-aff4a000 rw-p 00000000 00:00 0 422 - ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] 423 - 424 398 The /proc/PID/smaps is an extension based on maps, showing the memory 425 399 consumption for each of the process's mappings. For each of mappings there 426 400 is a series of lines such as the following:
+5 -4
fs/proc/array.c
··· 412 412 mm = get_task_mm(task); 413 413 if (mm) { 414 414 vsize = task_vsize(mm); 415 - if (permitted) { 416 - eip = KSTK_EIP(task); 417 - esp = KSTK_ESP(task); 418 - } 415 + /* 416 + * esp and eip are intentionally zeroed out. There is no 417 + * non-racy way to read them without freezing the task. 418 + * Programs that need reliable values can use ptrace(2). 419 + */ 419 420 } 420 421 421 422 get_task_comm(tcomm, task);
+10 -19
fs/proc/task_mmu.c
··· 266 266 * /proc/PID/maps that is the stack of the main task. 267 267 */ 268 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; 272 - 273 - if (is_pid) { 274 - stack = vma->vm_start <= vma->vm_mm->start_stack && 275 - vma->vm_end >= vma->vm_mm->start_stack; 276 - } else { 277 - struct inode *inode = priv->inode; 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; 271 + /* 272 + * We make no effort to guess what a given thread considers to be 273 + * its "stack". It's not even well-defined for programs written 274 + * languages like Go. 275 + */ 276 + return vma->vm_start <= vma->vm_mm->start_stack && 277 + vma->vm_end >= vma->vm_mm->start_stack; 287 278 } 288 279 289 280 static void ··· 345 354 goto done; 346 355 } 347 356 348 - if (is_stack(priv, vma, is_pid)) 357 + if (is_stack(priv, vma)) 349 358 name = "[stack]"; 350 359 } 351 360 ··· 1660 1669 seq_file_path(m, file, "\n\t= "); 1661 1670 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { 1662 1671 seq_puts(m, " heap"); 1663 - } else if (is_stack(proc_priv, vma, is_pid)) { 1672 + } else if (is_stack(proc_priv, vma)) { 1664 1673 seq_puts(m, " stack"); 1665 1674 } 1666 1675
+9 -17
fs/proc/task_nommu.c
··· 124 124 } 125 125 126 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 129 struct mm_struct *mm = vma->vm_mm; 130 - int stack = 0; 131 130 132 - if (is_pid) { 133 - stack = vma->vm_start <= mm->start_stack && 134 - vma->vm_end >= mm->start_stack; 135 - } else { 136 - struct inode *inode = priv->inode; 137 - struct task_struct *task; 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; 131 + /* 132 + * We make no effort to guess what a given thread considers to be 133 + * its "stack". It's not even well-defined for programs written 134 + * languages like Go. 135 + */ 136 + return vma->vm_start <= mm->start_stack && 137 + vma->vm_end >= mm->start_stack; 146 138 } 147 139 148 140 /* ··· 176 184 if (file) { 177 185 seq_pad(m, ' '); 178 186 seq_file_path(m, file, ""); 179 - } else if (mm && is_stack(priv, vma, is_pid)) { 187 + } else if (mm && is_stack(priv, vma)) { 180 188 seq_pad(m, ' '); 181 189 seq_printf(m, "[stack]"); 182 190 }
+1 -1
include/linux/mm.h
··· 1391 1391 !vma_growsup(vma->vm_next, addr); 1392 1392 } 1393 1393 1394 - int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t); 1394 + int vma_is_stack_for_current(struct vm_area_struct *vma); 1395 1395 1396 1396 extern unsigned long move_page_tables(struct vm_area_struct *vma, 1397 1397 unsigned long old_addr, struct vm_area_struct *new_vma,
-1
mm/mprotect.c
··· 25 25 #include <linux/perf_event.h> 26 26 #include <linux/pkeys.h> 27 27 #include <linux/ksm.h> 28 - #include <linux/pkeys.h> 29 28 #include <asm/uaccess.h> 30 29 #include <asm/pgtable.h> 31 30 #include <asm/cacheflush.h>
+3 -1
mm/util.c
··· 230 230 } 231 231 232 232 /* Check if the vma is being used as a stack by this task */ 233 - int vma_is_stack_for_task(struct vm_area_struct *vma, struct task_struct *t) 233 + int vma_is_stack_for_current(struct vm_area_struct *vma) 234 234 { 235 + struct task_struct * __maybe_unused t = current; 236 + 235 237 return (vma->vm_start <= KSTK_ESP(t) && vma->vm_end >= KSTK_ESP(t)); 236 238 } 237 239
+1 -1
security/selinux/hooks.c
··· 3557 3557 } else if (!vma->vm_file && 3558 3558 ((vma->vm_start <= vma->vm_mm->start_stack && 3559 3559 vma->vm_end >= vma->vm_mm->start_stack) || 3560 - vma_is_stack_for_task(vma, current))) { 3560 + vma_is_stack_for_current(vma))) { 3561 3561 rc = current_has_perm(current, PROCESS__EXECSTACK); 3562 3562 } else if (vma->vm_file && vma->anon_vma) { 3563 3563 /*