Re: [PATCH v5 05/11] vsprintf: Consolidate handling of unknown pointer specifiers
From: Andy Shevchenko
Date: Wed Apr 25 2018 - 09:08:39 EST
On Wed, 2018-04-25 at 13:12 +0200, Petr Mladek wrote:
> There are few printk formats that make sense only with two or more
> specifiers. Also some specifiers make sense only when a kernel feature
> is enabled.
> The handling of unknown specifiers is strange, inconsistent, and
> even leaking the address. For example, netdev_bits() prints the
> non-hashed pointer value or clock() prints "(null)".
> Using WARN() looks like an overkill for this type of error. pr_warn()
> is not good either. It would by handled via printk_sage buffer and
> it might be hard to match it with the problematic string.
> A reasonable compromise seems to be writing the unknown format
> into the original string with a question mark, for example (%pC?).
> It should be self-explaining enough. Note that it is in brackets
> to follow the (null) style.
> + return valid_string(buf, end, "(%pG?)", spec);
> if (!IS_ENABLED(CONFIG_OF))
> - return valid_string(buf, end, "(!OF)", spec);
> + return valid_string(buf, end, "(%OF?)", spec);
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy