Re: [PATCH] vsprintf: Fix %pK with kptr_restrict == 0

From: Andy Shevchenko
Date: Wed Feb 09 2022 - 07:01:44 EST


On Tue, Feb 08, 2022 at 02:51:39PM +0100, Petr Mladek wrote:
> On Thu 2022-01-27 11:11:02, Christophe Leroy wrote:

...

> Instead, I would create:
>
> /*
> * default is to _not_ leak addresses, so hash before printing,
> * unless no_hash_pointers is specified on the command line.
> */
> static noinline_for_stack
> char *default_pointer(const char *fmt, char *buf, char *end, void *ptr,
> struct printf_spec spec)
> {
> if (unlikely(no_hash_pointers))
> return pointer_string(buf, end, ptr, spec);
>
> return ptr_to_id(buf, end, ptr, spec);
> }
>
> and use it in both hash_pointer() and pointer().

I like this idea.

--
With Best Regards,
Andy Shevchenko