Received: by 10.223.176.5 with SMTP id f5csp766492wra; Wed, 7 Feb 2018 07:13:45 -0800 (PST) X-Google-Smtp-Source: AH8x227Dt+l4SesdURGT+1EaHGbBKtF2cfNIKNG/pUOKuy2kuetBpO/EyPQfUfzXLSLRkl48Pydp X-Received: by 10.99.95.215 with SMTP id t206mr5182422pgb.132.1518016425479; Wed, 07 Feb 2018 07:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518016425; cv=none; d=google.com; s=arc-20160816; b=F+Jq7D0146w8T0kvS8WzbLgU3JxUrqJIWTfFoPyTr02CXgM0KT3/YvzSc1kfTw3C7V XAmchlw6OGDie5QOuDzuo+1f8KmiKxSnSHJcmjmqVoXI0txzvlen4mq9P6RbJKC3LSXr 7eVP5wvfMdH+rcdhTqVYAycGDPyz6Wo9Wb3jWyOksfVQz+ZyFpcPWSjGuMLiQCvd3CnL KxQRcO/U1ZPT5ZUwurkyg0WOre6Z7hcOUAGsBLreSwEZMxrkxu6EfWNZI2vpLcUFsb/5 FfYjJXdTyuK/2qSs1QD6MpBXSm/xBw62oJx6jiK1hWvpmjF9diI1zt8c5V+Bw3o2ar97 XQxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=jhR8SWjmJbH5RlhCqXu1fc0BS8dMC9QzDzJcSbDMRak=; b=hh/PdKAiY7fDnIC31MSOYaaodYO4HP7p0PAJnE2MSKT1fW9GgXFBVN2hRRbr5xQcaF nEiUWl1IfDNo5UnyTU03PYKxNNlgDcvvxAfpySfdhWrQlBAuXlHWU0O2WLya+Ac7GxH/ UmHyKE5jqfbG/WLd+VtxJSSbN+KJqrDSI1kYtl9vNTu9zNG/1aTnIfBOYAQdvichn3UI mMO+LQ9khauCowVEbCqxTTfy7JrDca7i6g9y6p2HjIR9XQz9RArsTgoxEPNmJFFp/v9p T2kFHB/XwATLY4OJr3rLAEp8lwtSOHfIeUrJSKaxQ+FOlDM3QDiKyWQgnDXs1jFoVjNY vxXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Z5TirUaq; 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 y3si1055785pgv.59.2018.02.07.07.13.31; Wed, 07 Feb 2018 07:13:45 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Z5TirUaq; 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 S1754579AbeBGPLP (ORCPT + 99 others); Wed, 7 Feb 2018 10:11:15 -0500 Received: from mail-qk0-f182.google.com ([209.85.220.182]:39096 "EHLO mail-qk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754389AbeBGPLO (ORCPT ); Wed, 7 Feb 2018 10:11:14 -0500 Received: by mail-qk0-f182.google.com with SMTP id d72so1469150qkc.6 for ; Wed, 07 Feb 2018 07:11:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=jhR8SWjmJbH5RlhCqXu1fc0BS8dMC9QzDzJcSbDMRak=; b=Z5TirUaqpK0GFhLiFoT6TFkZGLvd6qLrN1iurtRI0FB3A+7fV+OGxygAaAetiKZCvK sTd5yzZsIIEcUurgRmEXtVJ/x+Be5Mtx4oIMrgf5X9zNJOZKZW0zBd0BMUOftlsfqp0q bEAZ5Vpey0mBebMIlG0N7gZ1yTNeaqknO8mObAEep0mwR9IpdkKp0TWrIWit4wKL5rB5 /GgNtnnUCjhNfHhE/BM8a+Gd4fWb8x+eAWvnhBM4S2rb1jimFmUCG7PLizOlhkbzWpMn ZKCXMbO6OjkmXVw5m2JwntYy9f1wota/wHdPAFtO0rnsspB80VDUclobAU72ikJ7GUJK tNHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=jhR8SWjmJbH5RlhCqXu1fc0BS8dMC9QzDzJcSbDMRak=; b=kfxidEi6NTPMawPU1PX6vE8T+fOqkJUMUn/d0mWnwR2+TtdZPi5TpxsmLrE1vLRTAF 5wHzm80zFeTa+hwak13dDc5cLZ4QRXJeljVVhgfXAm080UA0nFPQ6GCm5TgjBlZi1+J1 VkSCvB5JW49/eLrITwuv346KBCinRAA5gIghlzKp8OOVsfMIu8pEl9YDKp9gETxkEkKj 3I4ZFB7im/V67Hc0/1b0y/NiXhAxY45kkOmtQm+UcZr6kcVe1vO764x47C2Mm5ZenFi/ mVLF6gPsNqcw0dlx3u2LryWiPJi41jvjtqKHteKGDYSLQVvrxy2ie8BErCxWb+811rtt SZLg== X-Gm-Message-State: APf1xPAXv3lI+xAl9U/dG4pB+pO47OaSOLm2RAveQSjGuPvRealW0vLe LFrMVlizMXmUh6eHgGBoLZ0C3vBZWogpLTucY2Q= X-Received: by 10.55.40.166 with SMTP id o38mr9563268qko.35.1518016273735; Wed, 07 Feb 2018 07:11:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.39.197 with HTTP; Wed, 7 Feb 2018 07:11:13 -0800 (PST) In-Reply-To: <20180207150328.nuk7f76nutq2trcg@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> From: Geert Uytterhoeven Date: Wed, 7 Feb 2018 16:11:13 +0100 X-Google-Sender-Auth: -urN2c4tNmHOdJRggXi5EMWxEtY Message-ID: Subject: Re: [PATCH] vsprintf: avoid misleading "(null)" for %px To: Petr Mladek 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Petr, On Wed, Feb 7, 2018 at 4:03 PM, Petr Mladek wrote: > On Mon 2018-02-05 21:58:17, Adam Borowski wrote: >> On Tue, Feb 06, 2018 at 07:32:32AM +1100, Kees Cook wrote: >> > On Tue, Feb 6, 2018 at 7:15 AM, Tobin C. Harding wrote: >> > > On Tue, Feb 06, 2018 at 05:57:17AM +1100, Kees Cook wrote: >> > >> On Mon, Feb 5, 2018 at 8:44 PM, Petr Mladek wrote: >> > >> > On Sun 2018-02-04 18:45:21, Adam Borowski wrote: >> > >> >> Like %pK already does, print "00000000" instead. >> > >> >> >> > >> >> This confused people -- the convention is that "(null)" means you tried to >> > >> >> dereference a null pointer as opposed to printing the address. >> > > >> > > Leaving aside what is converting to %px. If we consider that using %px >> > > is meant to convey to us that we _really_ want the address, in hex hence >> > > the 'x', then it is not surprising that we will get "00000000"'s for a >> > > null pointer, right? Yes it is different to before but since we are >> > > changing the specifier does this not imply that there may be some >> > > change? >> > >> > I personally prefer 0000s, but if we're going to change this, we need >> > to be aware of the difference. >> >> It's easy to paint this bikeshed any color you guys want to: there's an "if" >> already. My preference is also 0000; NULL would be good, too -- I just >> don't want (null) as that has a special meaning in usual userspace >> implementations; (null) also fits well most other modes of %p as they show >> some object the argument points to. Confusion = wasted debugging time. > >> Let's recap: >> >> Currently: >> not-null null >> %pponies object's description (null) >> %px address (null) >> %pK hash hash >> >> I'd propose: >> not-null null >> %pponies object's description (null) >> %px address 00000000 >> %pK hash 00000000 > > It makes sense to me[*], so > > Reviewed-by: Petr Mladek > > It seems that all people agree with this change. But there was also some > confusion. I am going to give it few more days before I push it to > Linus. It means waiting for 4.16-rc3 because I will be without > reliable internet next week. Anyone, feel free to push it faster. > > > [*] 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. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds