Re: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols

From: Petr Mladek

Date: Tue Oct 27 2026 - 12:00:27 EST


On Fri 2026-10-23 18:46:24, 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. This affects passed pointers and
> callchain content since it is not part of the register dump.
>
> Use %p for the hashed pointer output if the pointer has not been
> resolved.
>
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -483,7 +483,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
> len = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
> buffer);
> if (!len)
> - return sprintf(buffer, "0x%lx", address - symbol_offset);
> + return sprintf(buffer, "0x%p", address - symbol_offset);

Both Sashiko and the intel test robot reports that this triggers:

kernel/kallsyms.c: In function '__sprint_symbol':
>> kernel/kallsyms.c:486:44: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'long unsigned int' [-Wformat=]
486 | return sprintf(buffer, "0x%p", address - symbol_offset);
| ~^ ~~~~~~~~~~~~~~~~~~~~~~~
| | |
| void * long unsigned int
| %ld

So, it should be:

return sprintf(buffer, "0x%p", (void *)(address - symbol_offset));

> offset -= symbol_offset;

Otherwise, it looks good to me. So, with the added cast:

Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>

There is no need to send v6. I could fix this when pushing.
I am going to wait few more days for potential feedback.
I will queue it for 7.5 unless anyone complains in the meantime.

Best Regards,
Petr