linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Adam Borowski <kilobyte@angband.pl>,
	Kees Cook <keescook@chromium.org>,
	"Tobin C. Harding" <me@tobin.cc>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Joe Perches <joe@perches.com>,
	"Roberts, William C" <william.c.roberts@intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Laight <David.Laight@aculab.com>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH] vsprintf: avoid misleading "(null)" for %px
Date: Wed, 7 Feb 2018 16:41:16 +0100	[thread overview]
Message-ID: <20180207154116.xvojw3bzmnmexkav@pathway.suse.cz> (raw)
In-Reply-To: <CAMuHMdVJZnbFrLxBZm1m6C+sR1MKuk3=G4RoYVkAgcxYDHgMGw@mail.gmail.com>

On Wed 2018-02-07 16:11:13, Geert Uytterhoeven wrote:
> Hi Petr,
> 
> On Wed, Feb 7, 2018 at 4:03 PM, Petr Mladek <pmladek@suse.com> 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

  reply	other threads:[~2018-02-07 15:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-04 17:45 [PATCH] vsprintf: avoid misleading "(null)" for %px Adam Borowski
2018-02-05  9:44 ` Petr Mladek
2018-02-05 10:03   ` Tobin C. Harding
2018-02-05 15:22     ` Adam Borowski
2018-02-05 16:49       ` Steven Rostedt
2018-02-05 17:36         ` Randy Dunlap
2018-02-05 20:19           ` Tobin C. Harding
2018-02-05 18:57   ` Kees Cook
2018-02-05 20:15     ` Tobin C. Harding
2018-02-05 20:32       ` Kees Cook
2018-02-05 20:58         ` Adam Borowski
2018-02-05 22:22           ` Tobin C. Harding
2018-02-06 18:43             ` Andy Shevchenko
2018-02-07 15:03           ` Petr Mladek
2018-02-07 15:11             ` Geert Uytterhoeven
2018-02-07 15:41               ` Petr Mladek [this message]
2018-02-07 15:48                 ` Geert Uytterhoeven
2018-02-08 15:29                 ` Andy Shevchenko
2018-02-09 12:03                   ` Petr Mladek
2018-02-14 14:35                     ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180207154116.xvojw3bzmnmexkav@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=David.Laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=geert@linux-m68k.org \
    --cc=joe@perches.com \
    --cc=keescook@chromium.org \
    --cc=kilobyte@angband.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@tobin.cc \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=william.c.roberts@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).