diff options
author | Jake Edge <jake@lwn.net> | 2009-05-04 14:51:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-05-04 18:14:23 -0400 |
commit | f83ce3e6b02d5e48b3a43b001390e2b58820389d (patch) | |
tree | 71c57abf4f9d259f5bfa22deaf724db85738f862 /fs | |
parent | 7fdf523067666b0eaff330f362401ee50ce187c4 (diff) |
proc: avoid information leaks to non-privileged processes
By using the same test as is used for /proc/pid/maps and /proc/pid/smaps,
only allow processes that can ptrace() a given process to see information
that might be used to bypass address space layout randomization (ASLR).
These include eip, esp, wchan, and start_stack in /proc/pid/stat as well
as the non-symbolic output from /proc/pid/wchan.
ASLR can be bypassed by sampling eip as shown by the proof-of-concept
code at http://code.google.com/p/fuzzyaslr/ As part of a presentation
(http://www.cr0.org/paper/to-jt-linux-alsr-leak.pdf) esp and wchan were
also noted as possibly usable information leaks as well. The
start_stack address also leaks potentially useful information.
Cc: Stable Team <stable@kernel.org>
Signed-off-by: Jake Edge <jake@lwn.net>
Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/proc/array.c | 13 | ||||
-rw-r--r-- | fs/proc/base.c | 5 |
2 files changed, 13 insertions, 5 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c index 7e4877d9dcb5..725a650bbbb8 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <linux/delayacct.h> | 80 | #include <linux/delayacct.h> |
81 | #include <linux/seq_file.h> | 81 | #include <linux/seq_file.h> |
82 | #include <linux/pid_namespace.h> | 82 | #include <linux/pid_namespace.h> |
83 | #include <linux/ptrace.h> | ||
83 | #include <linux/tracehook.h> | 84 | #include <linux/tracehook.h> |
84 | 85 | ||
85 | #include <asm/pgtable.h> | 86 | #include <asm/pgtable.h> |
@@ -352,6 +353,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
352 | char state; | 353 | char state; |
353 | pid_t ppid = 0, pgid = -1, sid = -1; | 354 | pid_t ppid = 0, pgid = -1, sid = -1; |
354 | int num_threads = 0; | 355 | int num_threads = 0; |
356 | int permitted; | ||
355 | struct mm_struct *mm; | 357 | struct mm_struct *mm; |
356 | unsigned long long start_time; | 358 | unsigned long long start_time; |
357 | unsigned long cmin_flt = 0, cmaj_flt = 0; | 359 | unsigned long cmin_flt = 0, cmaj_flt = 0; |
@@ -364,11 +366,14 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
364 | 366 | ||
365 | state = *get_task_state(task); | 367 | state = *get_task_state(task); |
366 | vsize = eip = esp = 0; | 368 | vsize = eip = esp = 0; |
369 | permitted = ptrace_may_access(task, PTRACE_MODE_READ); | ||
367 | mm = get_task_mm(task); | 370 | mm = get_task_mm(task); |
368 | if (mm) { | 371 | if (mm) { |
369 | vsize = task_vsize(mm); | 372 | vsize = task_vsize(mm); |
370 | eip = KSTK_EIP(task); | 373 | if (permitted) { |
371 | esp = KSTK_ESP(task); | 374 | eip = KSTK_EIP(task); |
375 | esp = KSTK_ESP(task); | ||
376 | } | ||
372 | } | 377 | } |
373 | 378 | ||
374 | get_task_comm(tcomm, task); | 379 | get_task_comm(tcomm, task); |
@@ -424,7 +429,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
424 | unlock_task_sighand(task, &flags); | 429 | unlock_task_sighand(task, &flags); |
425 | } | 430 | } |
426 | 431 | ||
427 | if (!whole || num_threads < 2) | 432 | if (permitted && (!whole || num_threads < 2)) |
428 | wchan = get_wchan(task); | 433 | wchan = get_wchan(task); |
429 | if (!whole) { | 434 | if (!whole) { |
430 | min_flt = task->min_flt; | 435 | min_flt = task->min_flt; |
@@ -476,7 +481,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
476 | rsslim, | 481 | rsslim, |
477 | mm ? mm->start_code : 0, | 482 | mm ? mm->start_code : 0, |
478 | mm ? mm->end_code : 0, | 483 | mm ? mm->end_code : 0, |
479 | mm ? mm->start_stack : 0, | 484 | (permitted && mm) ? mm->start_stack : 0, |
480 | esp, | 485 | esp, |
481 | eip, | 486 | eip, |
482 | /* The signal information here is obsolete. | 487 | /* The signal information here is obsolete. |
diff --git a/fs/proc/base.c b/fs/proc/base.c index aa763ab00777..fb45615943c2 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -322,7 +322,10 @@ static int proc_pid_wchan(struct task_struct *task, char *buffer) | |||
322 | wchan = get_wchan(task); | 322 | wchan = get_wchan(task); |
323 | 323 | ||
324 | if (lookup_symbol_name(wchan, symname) < 0) | 324 | if (lookup_symbol_name(wchan, symname) < 0) |
325 | return sprintf(buffer, "%lu", wchan); | 325 | if (!ptrace_may_access(task, PTRACE_MODE_READ)) |
326 | return 0; | ||
327 | else | ||
328 | return sprintf(buffer, "%lu", wchan); | ||
326 | else | 329 | else |
327 | return sprintf(buffer, "%s", symname); | 330 | return sprintf(buffer, "%s", symname); |
328 | } | 331 | } |