[PATCH v2 2/2] kallsyms: Document why unresolved symbols are revealed

Sebastian Andrzej Siewior <[email protected]>
Newsgroups org.kernel.vger.linux-hardening,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
__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. However for post-mortem analysis of crashes it is helpful to see
the raw pointer if it is a corrupted pointer.

Document why raw unresolved pointers are printed.

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
---
 kernel/kallsyms.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index aec2f06858afd..983eae8d66f88 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -482,8 +482,13 @@ static int __sprint_symbol(char *buffer, unsigned long address,
 	address += symbol_offset;
 	len = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
 				       buffer);
-	if (!len)
+	if (!len) {
+		/*
+		 * Print the raw pointer to allow post-mortem analysis of corrupted
+		 * pointer in backtraces.
+		 */
 		return sprintf(buffer, "0x%lx", address - symbol_offset);
+	}
 
 	offset -= symbol_offset;
 
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.