aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-11-03 18:04:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-03 18:04:04 -0500
commit7eeef2abe87dc0d8c276f97ccfdb1f42d9d1e4d8 (patch)
tree69141bc10fab1bb9b8aaa94f87c617b9c813155c /fs/proc
parent6aa2fdb87cf01d7746955c600cbac352dc04d451 (diff)
parentb2f73922d119686323f14fbbe46587f863852328 (diff)
Merge branch 'core-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull wchan kernel address hiding from Ingo Molnar: "This fixes a wchan related information leak in /proc/PID/stat. There's a bit of an ABI twist to it: instead of setting the wchan field to 0 (which is our usual technique) we set it conditionally to a 0/1 flag to keep ABI compatibility with older procps versions that only fetches /proc/PID/wchan (symbolic names) if the absolute wchan address is nonzero" * 'core-debug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: fs/proc, core/debug: Don't expose absolute kernel addresses via wchan
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/array.c16
-rw-r--r--fs/proc/base.c9
2 files changed, 17 insertions, 8 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index f60f0121e331..eed2050db9be 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -375,7 +375,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
375static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, 375static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
376 struct pid *pid, struct task_struct *task, int whole) 376 struct pid *pid, struct task_struct *task, int whole)
377{ 377{
378 unsigned long vsize, eip, esp, wchan = ~0UL; 378 unsigned long vsize, eip, esp, wchan = 0;
379 int priority, nice; 379 int priority, nice;
380 int tty_pgrp = -1, tty_nr = 0; 380 int tty_pgrp = -1, tty_nr = 0;
381 sigset_t sigign, sigcatch; 381 sigset_t sigign, sigcatch;
@@ -507,7 +507,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
507 seq_put_decimal_ull(m, ' ', task->blocked.sig[0] & 0x7fffffffUL); 507 seq_put_decimal_ull(m, ' ', task->blocked.sig[0] & 0x7fffffffUL);
508 seq_put_decimal_ull(m, ' ', sigign.sig[0] & 0x7fffffffUL); 508 seq_put_decimal_ull(m, ' ', sigign.sig[0] & 0x7fffffffUL);
509 seq_put_decimal_ull(m, ' ', sigcatch.sig[0] & 0x7fffffffUL); 509 seq_put_decimal_ull(m, ' ', sigcatch.sig[0] & 0x7fffffffUL);
510 seq_put_decimal_ull(m, ' ', wchan); 510
511 /*
512 * We used to output the absolute kernel address, but that's an
513 * information leak - so instead we show a 0/1 flag here, to signal
514 * to user-space whether there's a wchan field in /proc/PID/wchan.
515 *
516 * This works with older implementations of procps as well.
517 */
518 if (wchan)
519 seq_puts(m, " 1");
520 else
521 seq_puts(m, " 0");
522
511 seq_put_decimal_ull(m, ' ', 0); 523 seq_put_decimal_ull(m, ' ', 0);
512 seq_put_decimal_ull(m, ' ', 0); 524 seq_put_decimal_ull(m, ' ', 0);
513 seq_put_decimal_ll(m, ' ', task->exit_signal); 525 seq_put_decimal_ll(m, ' ', task->exit_signal);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index b25eee4cead5..29595af32866 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -430,13 +430,10 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
430 430
431 wchan = get_wchan(task); 431 wchan = get_wchan(task);
432 432
433 if (lookup_symbol_name(wchan, symname) < 0) { 433 if (wchan && ptrace_may_access(task, PTRACE_MODE_READ) && !lookup_symbol_name(wchan, symname))
434 if (!ptrace_may_access(task, PTRACE_MODE_READ))
435 return 0;
436 seq_printf(m, "%lu", wchan);
437 } else {
438 seq_printf(m, "%s", symname); 434 seq_printf(m, "%s", symname);
439 } 435 else
436 seq_putc(m, '0');
440 437
441 return 0; 438 return 0;
442} 439}