Re: [PATCH] vsprintf: don't obfuscate NULL and error pointers

From: Ilya Dryomov
Date: Tue Feb 18 2020 - 15:18:42 EST


On Tue, Feb 18, 2020 at 8:39 PM Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Tue, Feb 18, 2020 at 11:31 AM Adam Borowski <kilobyte@xxxxxxxxxx> wrote:
> >
> > Either "0" or "NULL" (or "â" if you allow cp437-subset Unicode ) wouldn't
> > cause such confusion.
>
> An all-uppercase "NULL" probably matches the error code printout
> syntax better too, and is more clearly a pointer.
>
> And with %pe you can't assume columnar output anyway (unless you
> explicitly ask for some width), so the length of the output cannot
> matter.
>
> So yeah, I agree. To extend on Ilya's example:
>
> ptr error-ptr NULL
> %p: 0000000001f8cc5b fffffffffffffff2 0000000000000000
> %pK, kptr = 0: 0000000001f8cc5b fffffffffffffff2 0000000000000000
> %px: ffff888048c04020 fffffffffffffff2 0000000000000000
> %pK, kptr = 1: ffff888048c04020 fffffffffffffff2 0000000000000000
> %pK, kptr = 2: 0000000000000000 0000000000000000 0000000000000000
> %p: 0000000001f8cc5b -EFAULT NULL

^^^
I assume you meant %pe here.

>
> would seem to be a sane output format. Hmm?

Looks sensible to me. Without this patch NULL is obfuscated for
both %p and %pe though. Do you want this patch amended or prefer
a follow-up for %pe "0000000000000000" -> "NULL" so that it can be
discussed separately?

Thanks,

Ilya