Re: [PATCH] vsprintf: avoid misleading "(null)" for %px

From: Kees Cook
Date: Mon Feb 05 2018 - 13:57:38 EST


On Mon, Feb 5, 2018 at 8:44 PM, Petr Mladek <pmladek@xxxxxxxx> wrote:
> Hi,
>
> I add people who actively commented on adding %px modifier,
> see the thread starting at
> https://lkml.kernel.org/r/1511921105-3647-5-git-send-email-me@xxxxxxxx
>
> Just for reference. It seems to be related to the commit 9f36e2c448007b54
> ("printk: use %pK for /proc/kallsyms and /proc/modules").
>
>
> 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.
>
> By other words, this avoids regressions when people convert
> %x to %px. Do I get it right, please?

Nothing should be converting from %x to %px, it's %p to %px. %p print
"(null)" for 0x0, so it would be surprising for a conversion from %p
to %px to change that. (Though generally speaking "(null)" is never
useful...)

-Kees

--
Kees Cook
Pixel Security