From: Petr Mladek <pmladek@suse.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Kees Cook <kees@kernel.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Tycho Andersen <tycho@tycho.pizza>,
Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
Date: Tue, 27 Oct 2026 17:00:12 +0100 [thread overview]
Message-ID: <auDKjGxSieq6WAmW@pathway.suse.cz> (raw)
In-Reply-To: <20261023-vsprintf_kallsym-v5-2-57ff92187c1d@linutronix.de>
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
prev parent reply other threads:[~2026-10-27 16:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 16:46 [PATCH v5 0/2] vsprintf: Don't leak pointers Sebastian Andrzej Siewior
2026-10-23 16:46 ` [PATCH v5 1/2] vsprintf: Don't leak pointers for %ps without KALLSYMS enabled Sebastian Andrzej Siewior
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-25 14:51 ` Andy Shevchenko
2026-10-27 16:00 ` Petr Mladek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auDKjGxSieq6WAmW@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=namhyung@kernel.org \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tycho@tycho.pizza \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®