From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755614AbbJAKjV (ORCPT ); Thu, 1 Oct 2015 06:39:21 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:36605 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbbJAKjS (ORCPT ); Thu, 1 Oct 2015 06:39:18 -0400 Date: Thu, 1 Oct 2015 12:39:14 +0200 From: Ingo Molnar To: Andrey Ryabinin Cc: Kees Cook , Thomas Gleixner , Andy Lutomirski , Dmitry Vyukov , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , Borislav Petkov , Denys Vlasenko , "x86@kernel.org" , LKML , Kostya Serebryany , Alexander Potapenko , Andrey Konovalov , Sasha Levin , Andi Kleen , kasan-dev , Linus Torvalds , Peter Zijlstra , Andrew Morton , Al Viro Subject: Re: [PATCH v3] fs/proc, core/debug: Don't expose absolute kernel addresses via wchan Message-ID: <20151001103913.GA11812@gmail.com> References: <20150930071537.GA19048@gmail.com> <20150930135917.GA3285@gmail.com> <20151001075715.GA23430@gmail.com> <20151001092914.GC6543@gmail.com> <560D07FC.2000705@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <560D07FC.2000705@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Andrey Ryabinin 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