Re: [PATCH] vsprintf: Make "null" pointer dereference more robust

From: Linus Torvalds
Date: Thu Mar 08 2018 - 11:45:25 EST


On Thu, Mar 8, 2018 at 6:18 AM, Petr Mladek <pmladek@xxxxxxxx> wrote:
> On Wed 2018-03-07 10:34:17, Linus Torvalds wrote:
>>
>> Guess what happens now to any crash report if it uses %p and there is
>> anything wrong with the VM?
>
> This patch does _not_ affect plain %p, %px, and %pK!

Umm. Look again. It _does_ affect plain %p.

You're correct that it doesn't affect %px and %pK, since those never
printed out (null) in the first place.

> It affects %s and %p* modifiers that need to read data from the
> given address.

_If_ that was what the patch did, it would be fine.

But it isn't.

It not only affects %p, but it also affects %pS and friends (sSfFB),
that do not access the location (well, on some architectures those
might, to dereference a function descriptor, but then they will check
the address range).

So that patch really is completely broken for the reasons I outlined.

Now, if it was fixed to what you apparently *intended* to do, then
that would be ok.

Linus