From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751983AbdKIDgD (ORCPT ); Wed, 8 Nov 2017 22:36:03 -0500 Received: from smtprelay0002.hostedemail.com ([216.40.44.2]:59830 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751495AbdKIDgC (ORCPT ); Wed, 8 Nov 2017 22:36:02 -0500 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::::::::::::::::::::::::::::::::::::::::,RULES_HIT:41:334:355:368:369:379:541:599:800:960:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2899:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3872:3874:5007:6261:6691:6742:6743:7875:8603:10004:10400:10848:10967:11232:11658:11914:12555:12740:12760:12895:13069:13161:13229:13311:13357:13439:14096:14097:14181:14659:14721:21080:21324:21627:30003:30029:30054:30089:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: rifle03_5113ba9b3ad02 X-Filterd-Recvd-Size: 3244 Date: Wed, 8 Nov 2017 22:35:55 -0500 From: Steven Rostedt To: "Tobin C. Harding" 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 , Djalal Harouni , "Paul E. McKenney" , Andy Lutomirski , Peter Zijlstra , David Miller , Network Development , linux-kernel@vger.kernel.org Subject: Re: [PATCH] kallsyms: don't leak address when printing symbol Message-ID: <20171108223555.52c01531@vmware.local.home> In-Reply-To: <1510192229-20038-1-git-send-email-me@tobin.cc> References: <1510192229-20038-1-git-send-email-me@tobin.cc> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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);