Re: [PATCH 3/3] lib/vsprintf: make-printk-non-secret printks all addresses as unhashed

From: Timur Tabi
Date: Wed Feb 10 2021 - 12:28:42 EST




On 2/10/21 7:41 AM, Petr Mladek wrote:

The option causes that vsprintf() will not hash pointers. Yes, it is
primary used by printk(). But it is used also in some other
interfaces, especially trace_printk(), seq_buf() API. The naked
pointers might appear more or less anywhere, including procfs,
sysfs, debugfs.

Fair point. Shouldn't calls to seq_buf_printf() (and any printk usage that always exists in the context of a user-space process) use %pK anyway?

Hmmm.... maybe vsprintf() should automatically replace %p with %pK if it detects a user-space context?

IMHO, we should fix this. The long discussion was about how to make
this option safe. Users should be aware that it is not only about
the kernel log.

Agreed.

I suggest to rename the parameter "debug_never_hash_pointer" and use
the same name for the parameter and the variable.

Will do.

We also should make the warning more generic. I suggest to replace the
first paragraph with something like:

pr_warn("** The hashing of printed pointers has been disabled **\n");
pr_warn("** for debugging purposes. **\n");

Feel free to use a better wording. I am not a native speaker.

You could have fooled me.

Of course, also kernel-parameters.txt has to be updated accordingly.

Ok.