Received: by 10.223.176.5 with SMTP id f5csp796948wra; Wed, 7 Feb 2018 07:42:31 -0800 (PST) X-Google-Smtp-Source: AH8x2247VRsvAQeBonH6xarl61T0lElixIAeFInS6hGB8ISaUmL2ojCFPrQSobH0nOcFgZAhPXqf X-Received: by 10.98.159.200 with SMTP id v69mr6354528pfk.236.1518018151686; Wed, 07 Feb 2018 07:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518018151; cv=none; d=google.com; s=arc-20160816; b=cki4ZNeyX+6GvBdeuydYLFdWfFsn34TENGNHMdoU8iwyGxLPzK+uQH246hhrcEUWY+ JEGl+ZoiXOy8s1TvXrR1hl7TFZtlOHQPCIEoACBV2Rv7rxVWxQrlGge2AQyXAl4fs6X6 T9cW0qVrSBhGF/hzyQ7fMXgFrtMjutq38njsaaWVSKDp8PllHbHJcqp1fHchNd+nC81Z Yg0WvSaJNo7hySBAlNrESBTtcPWJNo6gcy6UqtkJTUWXozG7cbl0K6UtHBb9sdo+Epnx AmDBNlsoWBxnAYHpmhtiB3145P+FR4cLfTneFWpmZ6ZBDhJRMThiOi8im9ia2APxrsBv xXJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=KTdt0VtxFKJTaQcCL91JV4b3uT4qYrlN9f111sPGiNo=; b=SjViHg0YXg58UUBPyzLrAt3mu3X65EgfFjxYQLZuv5Y7Ws/TIe2Eg8F84r28qFiEeQ 2ps2jwwEMNOfjlGz9177MR6XVoPm0WlFcPyNWj0wl9mJ7d3Oe0pN82Si+YuyVLLu+zRW bUCtTJtESPOVwGjbOQkrzn4YQJSts6OeV0Jo87S7bCMJhj3E3esZQGgV5V+S9H+uKK9N Bnukp4/2+NYb4yvulmEwWWDx2OPTmgXSh+h3P7RTmgkydImwXGDRlniD5zeY8TLWxsG1 MEqVBGudQJKozaNlkrZ7eadK5oPIsfiPQrsBrWY4p7DYUHvK2+9RDj+XZfMo6Xrgc2h0 stqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g66si1239069pfa.84.2018.02.07.07.42.17; Wed, 07 Feb 2018 07:42:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754612AbeBGPlV (ORCPT + 99 others); Wed, 7 Feb 2018 10:41:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:55041 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754166AbeBGPlU (ORCPT ); Wed, 7 Feb 2018 10:41:20 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9C881ADC6; Wed, 7 Feb 2018 15:41:17 +0000 (UTC) Date: Wed, 7 Feb 2018 16:41:16 +0100 From: Petr Mladek To: Geert Uytterhoeven Cc: Adam Borowski , Kees Cook , "Tobin C. Harding" , Sergey Senozhatsky , Steven Rostedt , LKML , Andrew Morton , Joe Perches , "Roberts, William C" , Linus Torvalds , David Laight , Randy Dunlap Subject: Re: [PATCH] vsprintf: avoid misleading "(null)" for %px Message-ID: <20180207154116.xvojw3bzmnmexkav@pathway.suse.cz> References: <20180204174521.21383-1-kilobyte@angband.pl> <20180205094438.pfd7ffymlvklpxe7@pathway.suse.cz> <20180205201555.GQ29988@eros> <20180205205817.72dy7e7xzjcnwmhs@angband.pl> <20180207150328.nuk7f76nutq2trcg@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2018-02-07 16:11:13, Geert Uytterhoeven wrote: > Hi Petr, > > On Wed, Feb 7, 2018 at 4:03 PM, Petr Mladek wrote: > > [*] I made some archaeology: > > > > The "(null)" string was added by the commit d97106ab53f812910 > > ("Make %p print '(null)' for NULL pointers"). > > > > It was a generic solution to prevent eventual crashes, see > > https://lkml.kernel.org/r/1230979341-23029-1-git-send-email-xyzzy@speakeasy.org > > > > From this point, printing 00000000 for %px looks perfectly fine because > > it does not crash. > > > > In fact, it would have made perfect sense to print 00000000 for pure > > %p because it did not crash. But nobody has cared about the eventual > > confusion yet. > > > > I am not sure if it makes sense to change the pure %p handling > > now. Note that printing "(null)" has the advantage that we > > get this string instead of the hash ;-) > > Note that "(null)" is also used for printing strings, where you do dereference > the pointer, unlike for printing pointers. > In addition, "(null)" for strings is not just printed for real NULL > pointers, but > also for anything pointing within the first page of virtual memory. We are on the safe side. "(null)" for "%s" is handled separately, see string() function in lib/vsprintf.c. To make it clear. I was talking about "%p" format that is handled in the pointer() function in lib/vsprintf.c. The "(null)" makes sense only for the many modifiers that do deference of the pointer, e.g. "%pa", "%pE", "%ph". It makes less sense for the pure "%p" used without any modifier. Well, it actually started to makes some sense after we started printing the hash instead of the real pointer value. Best Regards, Petr