From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbdJZE5d (ORCPT ); Thu, 26 Oct 2017 00:57:33 -0400 Received: from smtprelay0131.hostedemail.com ([216.40.44.131]:56833 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751584AbdJZE53 (ORCPT ); Thu, 26 Oct 2017 00:57:29 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:968: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:2691:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3872:4250:4321:5007:6119:6691:6742:6743:8660:10004:10400:10848:11232:11658:11914:12296:12555:12740:12760:12895:13069:13148:13161:13229:13230:13311:13357:13439:14096:14097:14181:14659:14721:21080:21627:30054:30070: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:17,LUA_SUMMARY:none X-HE-Tag: bomb20_7aee280df5523 X-Filterd-Recvd-Size: 2965 Message-ID: <1508993843.10651.22.camel@perches.com> Subject: Re: [PATCH V8 1/2] printk: remove tabular output for NULL pointer From: Joe Perches To: "Tobin C. Harding" , kernel-hardening@lists.openwall.com Cc: "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 , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni , linux-kernel@vger.kernel.org Date: Wed, 25 Oct 2017 21:57:23 -0700 In-Reply-To: <1508986436-31966-2-git-send-email-me@tobin.cc> References: <1508986436-31966-1-git-send-email-me@tobin.cc> <1508986436-31966-2-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 Thu, 2017-10-26 at 13:53 +1100, Tobin C. Harding wrote: > Currently pointer() checks for a NULL pointer argument and then if so > attempts to print "(null)" with _some_ standard width. This width cannot > correctly be ascertained here because many of the printk specifiers > print pointers of varying widths. I believe this is not a good change. Only pointers without a extension call pointer() > Remove the attempt to print NULL pointers with a correct width. the correct width for a %p is the default width. The correct width for %p is unknown. > Signed-off-by: Tobin C. Harding > --- > lib/vsprintf.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > index 86c3385b9eb3..16a587aed40e 100644 > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -1710,15 +1710,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, > { > const int default_width = 2 * sizeof(void *); > > - if (!ptr && *fmt != 'K') { > - /* > - * Print (null) with the same width as a pointer so it makes > - * tabular output look nice. > - */ > - if (spec.field_width == -1) > - spec.field_width = default_width; > + if (!ptr && *fmt != 'K') > return string(buf, end, "(null)", spec); > - } > > switch (*fmt) { > case 'F':