From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Rostedt Subject: Re: [PATCH] kallsyms: don't leak address when printing symbol Date: Wed, 8 Nov 2017 22:35:55 -0500 Message-ID: <20171108223555.52c01531@vmware.local.home> References: <1510192229-20038-1-git-send-email-me@tobin.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: kernel-hardening@lists.openwall.com, "Jason A. Donenfeld" , Theodore Ts'o , Linus Torvalds , Kees Cook , Paolo Bonzini , Tycho Andersen , "Roberts, William C" , Tejun Heo , Jordan Glover , Greg KH , Petr Mladek , Joe Perches , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Chris Fries , Dave Weinstein , Daniel Micay Return-path: In-Reply-To: <1510192229-20038-1-git-send-email-me@tobin.cc> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Thu, 9 Nov 2017 12:50:29 +1100 "Tobin C. Harding" wrote: > Currently if a pointer is printed using %p[ssB] and the symbol is not > found (kallsyms_lookup() fails) then we print the actual address. This > leaks kernel addresses. We should instead print something _safe_. > > Print "" instead of kernel address. Ug, ftrace requires this to work as is, as it uses it to print some addresses that may or may not be a symbol. If anything, can this return a success or failure if it were to find a symbol or not, and then something like ftrace could decide to use %x if it does not. And yes, ftrace leaks kernel addresses all over the place, that's just the nature of tracing the kernel. -- Steve > > Signed-off-by: Tobin C. Harding > --- > kernel/kallsyms.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c > index 127e7cfafa55..182e7592be9c 100644 > --- a/kernel/kallsyms.c > +++ b/kernel/kallsyms.c > @@ -390,7 +390,7 @@ static int __sprint_symbol(char *buffer, unsigned long address, > address += symbol_offset; > name = kallsyms_lookup(address, &size, &offset, &modname, buffer); > if (!name) > - return sprintf(buffer, "0x%lx", address - symbol_offset); > + return sprintf(buffer, ""); > > if (name != buffer) > strcpy(buffer, name);