Skip to content

Commit 0a1eb2d

Browse files
amlutoIngo Molnar
authored andcommitted
fs/proc: Stop reporting eip and esp in /proc/PID/stat
Reporting these fields on a non-current task is dangerous. If the task is in any state other than normal kernel code, they may contain garbage or even kernel addresses on some architectures. (x86_64 used to do this. I bet lots of architectures still do.) With CONFIG_THREAD_INFO_IN_TASK=y, it can OOPS, too. As far as I know, there are no use programs that make any material use of these fields, so just get rid of them. Reported-by: Jann Horn <[email protected]> Signed-off-by: Andy Lutomirski <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Cc: Al Viro <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Linux API <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Tetsuo Handa <[email protected]> Cc: Tycho Andersen <[email protected]> Link: http://lkml.kernel.org/r/a5fed4c3f4e33ed25d4bb03567e329bc5a712bcc.1475257877.git.luto@kernel.org Signed-off-by: Ingo Molnar <[email protected]>
1 parent 137baab commit 0a1eb2d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/proc/array.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
412412
mm = get_task_mm(task);
413413
if (mm) {
414414
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+
*/
419420
}
420421

421422
get_task_comm(tcomm, task);

0 commit comments

Comments
 (0)