[PATCH v5 2/2] kallsyms: Don't leak pointers for unresolved symbols
From: Sebastian Andrzej Siewior
Date: Fri Oct 23 2026 - 12:48:21 EST
__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.
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
kernel/kallsyms.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index aec2f06858afd..6a3e0ded8df1a 100644
--- 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);
offset -= symbol_offset;
--
2.55.0