From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757603AbdLRAEV (ORCPT ); Sun, 17 Dec 2017 19:04:21 -0500 Received: from smtprelay0112.hostedemail.com ([216.40.44.112]:56300 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757112AbdLRAET (ORCPT ); Sun, 17 Dec 2017 19:04:19 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 30,2,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::,RULES_HIT:41:334:355:368:369:379:541:569:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3868:3870:3871:3874:4321:5007:6119:10004:10400:10848:11026:11232:11473:11658:11914:12043:12438:12740:12760:12895:13069:13095:13311:13357:13439:14659:14721:21080:21433:21451:21627:30003:30054:30089: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:1,LUA_SUMMARY:none X-HE-Tag: party81_4272eb6613d21 X-Filterd-Recvd-Size: 2477 Message-ID: <1513555454.31581.43.camel@perches.com> Subject: Re: [PATCH 2/3] vsprintf: print if symbol not found From: Joe Perches To: "Tobin C. Harding" , kernel-hardening@lists.openwall.com Cc: Steven Rostedt , Tycho Andersen , Linus Torvalds , Kees Cook , Andrew Morton , Daniel Borkmann , Masahiro Yamada , Alexei Starovoitov , linux-kernel@vger.kernel.org, Network Development Date: Sun, 17 Dec 2017 16:04:14 -0800 In-Reply-To: <1513554812-13014-3-git-send-email-me@tobin.cc> References: <1513554812-13014-1-git-send-email-me@tobin.cc> <1513554812-13014-3-git-send-email-me@tobin.cc> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-12-18 at 10:53 +1100, Tobin C. Harding wrote: > Depends on: commit bd6b239cdbb2 ("kallsyms: don't leak address when > symbol not found") > > Currently vsprintf for specifiers %p[SsB] relies on the behaviour of > kallsyms (sprint_symbol()) and prints the actual address if a symbol is > not found. Previous patch changes this behaviour so tha sprint_symbol() tha->that > returns an error if symbol not found. With this patch in place we can > print a sanitized message '' instead of leaking the address. > > Print '' for printk specifier %s[sSB] if no symbol is found. %s->%ps > diff --git a/include/linux/kernel.h b/include/linux/kernel.h [] > @@ -460,6 +460,8 @@ char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); > extern __printf(2, 0) > const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args); > > +extern int string_is_no_symbol(const char *s); > + [] > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > > +#define PRINTK_NO_SYMBOL_STR "" "" ? "not found"? [] > +int string_is_no_symbol(const char *s) > +{ > + return !!strstr(s, PRINTK_NO_SYMBOL_STR); > +} > +EXPORT_SYMBOL(string_is_no_symbol); Why should string_is_no_symbol be exported?