* Re: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
2026-10-23 16:46 ` [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols Sebastian Andrzej Siewior
@ 2026-10-24 2:13 ` kernel test robot
2026-10-24 10:07 ` Andy Shevchenko
2026-10-27 16:00 ` Petr Mladek
2 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-10-24 2:13 UTC (permalink / raw)
To: Sebastian Andrzej Siewior, linux-kernel
Cc: oe-kbuild-all, Sebastian Andrzej Siewior, Andrew Morton,
Linux Memory Management List, Andy Shevchenko, Kees Cook,
Petr Mladek, Rasmus Villemoes, Sergey Senozhatsky,
Steven Rostedt, Tycho Andersen, Namhyung Kim
Hi Sebastian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 091b06388b117fefdcb63336ac09956a4914b961]
url: https://github.com/intel-lab-lkp/linux/commits/Sebastian-Andrzej-Siewior/vsprintf-Don-t-leak-pointers-for-ps-without-KALLSYMS-enabled/20261023-184623
base: 091b06388b117fefdcb63336ac09956a4914b961
patch link: https://lore.kernel.org/r/20261023-vsprintf_kallsym-v5-2-57ff92187c1d%40linutronix.de
patch subject: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
config: sh-rsk7201_defconfig (https://download.01.org/0day-ci/archive/20261024/202610241049.9evBxlP8-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261024/202610241049.9evBxlP8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610241049.9evBxlP8-lkp@intel.com/
All warnings (new ones prefixed by >>):
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
vim +486 kernel/kallsyms.c
469
470 /* Look up a kernel symbol and return it in a text buffer. */
471 static int __sprint_symbol(char *buffer, unsigned long address,
472 int symbol_offset, int add_offset, int add_buildid)
473 {
474 char *modname;
475 const unsigned char *buildid;
476 unsigned long offset, size;
477 int len;
478
479 /* Prevent module removal until modname and modbuildid are printed */
480 guard(rcu)();
481
482 address += symbol_offset;
483 len = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
484 buffer);
485 if (!len)
> 486 return sprintf(buffer, "0x%p", address - symbol_offset);
487
488 offset -= symbol_offset;
489
490 if (add_offset)
491 len += sprintf(buffer + len, "+%#lx/%#lx", offset, size);
492
493 if (modname) {
494 len += sprintf(buffer + len, " [%s", modname);
495 if (add_buildid)
496 len += append_buildid(buffer + len, modname, buildid);
497 len += sprintf(buffer + len, "]");
498 }
499
500 return len;
501 }
502
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
2026-10-23 16:46 ` [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols Sebastian Andrzej Siewior
2026-10-24 2:13 ` kernel test robot
@ 2026-10-24 10:07 ` Andy Shevchenko
2026-10-24 16:10 ` Sebastian Andrzej Siewior
2026-10-27 16:00 ` Petr Mladek
2 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2026-10-24 10:07 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, Andrew Morton, Kees Cook, Petr Mladek,
Rasmus Villemoes, Sergey Senozhatsky, Steven Rostedt,
Tycho Andersen, Namhyung Kim
On Fri, Oct 23, 2026 at 06:46:24PM +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. 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.
...
> - return sprintf(buffer, "0x%lx", address - symbol_offset);
> + return sprintf(buffer, "0x%p", address - symbol_offset);
Hmm... Do we need a 0x here? I believe it's embedded into %p output, no?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
2026-10-24 10:07 ` Andy Shevchenko
@ 2026-10-24 16:10 ` Sebastian Andrzej Siewior
2026-10-25 14:51 ` Andy Shevchenko
0 siblings, 1 reply; 8+ messages in thread
From: Sebastian Andrzej Siewior @ 2026-10-24 16:10 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-kernel, Andrew Morton, Kees Cook, Petr Mladek,
Rasmus Villemoes, Sergey Senozhatsky, Steven Rostedt,
Tycho Andersen, Namhyung Kim
On 2026-10-24 13:07:09 [+0300], Andy Shevchenko wrote:
>
> > - return sprintf(buffer, "0x%lx", address - symbol_offset);
> > + return sprintf(buffer, "0x%p", address - symbol_offset);
>
> Hmm... Do we need a 0x here? I believe it's embedded into %p output, no?
No, it does not. The %p does a fix digit size (different between 64 and
32 bit) without the 0x prefix.
Sebastian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
2026-10-24 16:10 ` Sebastian Andrzej Siewior
@ 2026-10-25 14:51 ` Andy Shevchenko
0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2026-10-25 14:51 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, Andrew Morton, Kees Cook, Petr Mladek,
Rasmus Villemoes, Sergey Senozhatsky, Steven Rostedt,
Tycho Andersen, Namhyung Kim
On Sat, Oct 24, 2026 at 06:10:29PM +0200, Sebastian Andrzej Siewior wrote:
> On 2026-10-24 13:07:09 [+0300], Andy Shevchenko wrote:
...
> > > - return sprintf(buffer, "0x%lx", address - symbol_offset);
> > > + return sprintf(buffer, "0x%p", address - symbol_offset);
> >
> > Hmm... Do we need a 0x here? I believe it's embedded into %p output, no?
>
> No, it does not. The %p does a fix digit size (different between 64 and
> 32 bit) without the 0x prefix.
Thanks for checking that. I dunno why my memory is weak in this sense...
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
2026-10-23 16:46 ` [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols Sebastian Andrzej Siewior
2026-10-24 2:13 ` kernel test robot
2026-10-24 10:07 ` Andy Shevchenko
@ 2026-10-27 16:00 ` Petr Mladek
2 siblings, 0 replies; 8+ messages in thread
From: Petr Mladek @ 2026-10-27 16:00 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, Andrew Morton, Andy Shevchenko, Kees Cook,
Rasmus Villemoes, Sergey Senozhatsky, Steven Rostedt,
Tycho Andersen, Namhyung Kim
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@suse.com>
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
^ permalink raw reply [flat|nested] 8+ messages in thread