Re: [PATCH v4 2/2] kallsyms: Don't leak pointers for unresolved symbols
From: Andy Shevchenko
Date: Mon Oct 19 2026 - 06:36:05 EST
On Mon, Oct 19, 2026 at 12:21:51PM +0200, Sebastian Andrzej Siewior wrote:
> __sprint_symbol() is supposed to resolve the passed address to a symbol
> name. If the symbol can not be resolved it will print the actual pointer
> that was passed. The pointer policy is to not reveal actual pointer
> values.
> For post-mortem analysis the pointer in the backtrace shouldn't be
> relevant. In BUG(), WARN() and panic() related backtraces the PC
> register will contain the actual value.
>
> Add snprintf_default_pointer() as a wrapper around default_pointer() and
> use it __sprint_symbol() if the pointer has not been resolved.
...
> +int snprintf_default_pointer(char *buf, unsigned int len, const void *ptr)
> +{
> + struct printf_spec spec = {
> + .base = 10,
> + .precision = -1,
> + .field_width = -1,
> + };
Isn't it the same as default_dec_spec?
> + unsigned int w;
> + char *endp;
> +
> + endp = default_pointer(buf, buf + len, ptr, spec);
> + w = min_t(unsigned int, len - 1, endp - buf);
May we avoid min_t()?
> + buf[w] = '\0';
> + return endp - buf;
> +}
--
With Best Regards,
Andy Shevchenko