From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932286AbdJZJhf (ORCPT ); Thu, 26 Oct 2017 05:37:35 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:57117 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbdJZJhc (ORCPT ); Thu, 26 Oct 2017 05:37:32 -0400 X-ME-Sender: Date: Thu, 26 Oct 2017 20:37:28 +1100 From: "Tobin C. Harding" To: Joe Perches 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 , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni , linux-kernel@vger.kernel.org Subject: Re: [PATCH V8 1/2] printk: remove tabular output for NULL pointer Message-ID: <20171026093728.GJ12341@eros> References: <1508986436-31966-1-git-send-email-me@tobin.cc> <1508986436-31966-2-git-send-email-me@tobin.cc> <1508993843.10651.22.camel@perches.com> <20171026062734.GH12341@eros> <1509005139.10651.39.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1509005139.10651.39.camel@perches.com> X-Mailer: Mutt 1.5.24 (2015-08-30) User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 26, 2017 at 01:05:39AM -0700, Joe Perches wrote: > On Thu, 2017-10-26 at 17:27 +1100, Tobin C. Harding wrote: > > Hi Joe, > > > > thanks for your review. > > > > On Wed, Oct 25, 2017 at 09:57:23PM -0700, Joe Perches wrote: > > > 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() > > > > Sorry, I don't understand what you mean here. All the %p specifier code is > > handled by pointer()? > > Sorry, I was imprecise/wrong. > > None of the %p extensions except %pK and %p > actually use this bit of the pointer() call. 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; return string(buf, end, "(null)", spec); } Is there something I'm missing here? This code reads like its all %p (including %p and %p) except %pK that hit this block when a NULL pointer is passed in. > All of the other valid %p extension uses do not end up > at this block being executed so it's effectively only regular > pointers being output by number() > > > > > Remove the attempt to print NULL pointers with a correct width. > > > > > > the correct width for a %p is the default width. > > > > It is the default width if we are printing addresses. Once we hash 64 > > bit address to a 32 bit identifier then we don't have a default width. > > Perhaps that 32 bit identifier should use leading 0's for > the default width. That's a fair comment. > aside: > > Why hash 64 bits to 32? > Why shouldn't the hash width be 64 bits on 64 bit systems? Quoted from Linus in an earlier thread discussing this change Date: Thu, 12 Oct 2017 11:37:22 -0700 Linus Torvalds wrote: In fact, I'd prefer mapping the pointer to a 32-bit value, even on 64-bit architectures. When people use these things for debugging and for identifying which device node or socket or whatever they are tracking, we're generally talking a (small) handful of different devices or whatever. Hope this helps, Tobin.