Messages in this thread | | | Date | Thu, 1 Oct 2015 12:39:14 +0200 | From | Ingo Molnar <> | Subject | Re: [PATCH v3] fs/proc, core/debug: Don't expose absolute kernel addresses via wchan |
| |
* Andrey Ryabinin <ryabinin.a.a@gmail.com> wrote:
> I think you misunderstood me. > Yes, this code currently doesn't use %pX, but it could: > > diff --git a/fs/proc/base.c b/fs/proc/base.c > index b25eee4..f58f66e 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -425,18 +425,7 @@ static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns, > static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns, > struct pid *pid, struct task_struct *task) > { > - unsigned long wchan; > - char symname[KSYM_NAME_LEN]; > - > - wchan = get_wchan(task); > - > - if (lookup_symbol_name(wchan, symname) < 0) { > - if (!ptrace_may_access(task, PTRACE_MODE_READ)) > - return 0; > - seq_printf(m, "%lu", wchan); > - } else { > - seq_printf(m, "%s", symname); > - } > + seq_printf(m, "%ps", get_wchan(task)); > > return 0; > } > > > There is a problem here, though. %ps will print absolute kernel address instead of symbol name > if KALLSYMS=n or if resolution of address failed. > So I was wondering, may be should just fix %ps ? > i.e. print 0 instead of absolute address if KALLSYMS=n or lookup failure?
There's another problem as well: your change loses the PTRACE_MODE_READ permission check.
But ... I think I like it open coded, which is good precisely because it will stay invariant even if we change details in the %ps/etc. debug output.
Thanks,
Ingo
| |