[PATCH v2 1/2] vsprintf: Don't leak pointers for %ps without KALLSYMS enabled

From: Sebastian Andrzej Siewior

Date: Fri Aug 21 2026 - 11:33:24 EST


The "%ps" format modifier prints the name of the symbol which is more
valuable in terms of debugging and does not leak the actual pointer.

Without KALLSYMS it will leak the pointer which is not intended. The
default policy for pointers is to print a hashed value and not to leak
the actual pointer.

For !KALLSYMS, print "(unknown)" for any symbol resolution. If hashed
pointer are disabled print the bare number.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
lib/vsprintf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 2bc6ef483576c..fcb63f22b1997 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1008,7 +1008,9 @@ char *symbol_string(char *buf, char *end, void *ptr,

return string_nocheck(buf, end, sym, spec);
#else
- return special_hex_number(buf, end, value, sizeof(void *));
+ if (unlikely(no_hash_pointers))
+ return special_hex_number(buf, end, value, sizeof(void *));
+ return string_nocheck(buf, end, "(unknown)", spec);
#endif
}

--
2.55.0