Skip to content

Commit 00d872d

Browse files
committed
tracing: Only return an adjusted address if it matches the kernel address
The trace_adjust_address() will take a given address and examine the persistent ring buffer to see if the address matches a module that is listed there. If it does not, it will just adjust the value to the core kernel delta. But if the address was for something that was not part of the core kernel text or data it should not be adjusted. Check the result of the adjustment and only return the adjustment if it lands in the current kernel text or data. If not, return the original address. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20250506102300.0ba2f9e0@gandalf.local.home Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 531ee10 commit 00d872d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/trace/trace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6032,6 +6032,7 @@ unsigned long trace_adjust_address(struct trace_array *tr, unsigned long addr)
60326032
struct trace_module_delta *module_delta;
60336033
struct trace_scratch *tscratch;
60346034
struct trace_mod_entry *entry;
6035+
unsigned long raddr;
60356036
int idx = 0, nr_entries;
60366037

60376038
/* If we don't have last boot delta, return the address */
@@ -6045,7 +6046,9 @@ unsigned long trace_adjust_address(struct trace_array *tr, unsigned long addr)
60456046
module_delta = READ_ONCE(tr->module_delta);
60466047
if (!module_delta || !tscratch->nr_entries ||
60476048
tscratch->entries[0].mod_addr > addr) {
6048-
return addr + tr->text_delta;
6049+
raddr = addr + tr->text_delta;
6050+
return __is_kernel(raddr) || is_kernel_core_data(raddr) ||
6051+
is_kernel_rodata(raddr) ? raddr : addr;
60496052
}
60506053

60516054
/* Note that entries must be sorted. */

0 commit comments

Comments
 (0)