From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH v2 3/4] tracing: Only return an adjusted address if it matches the kernel address
Date: Tue, 25 Mar 2025 17:38:48 -0400 [thread overview]
Message-ID: <20250325213919.790882670@goodmis.org> (raw)
In-Reply-To: 20250325213845.844200633@goodmis.org
From: Steven Rostedt <rostedt@goodmis.org>
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.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
kernel/trace/trace.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7ca8a0dbd4fa..85128ef96246 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -6023,6 +6023,7 @@ unsigned long trace_adjust_address(struct trace_array *tr, unsigned long addr)
struct trace_module_delta *module_delta;
struct trace_scratch *tscratch;
struct trace_mod_entry *entry;
+ unsigned long raddr;
int idx = 0, nr_entries;
/* If we don't have last boot delta, return the address */
@@ -6034,8 +6035,11 @@ unsigned long trace_adjust_address(struct trace_array *tr, unsigned long addr)
tscratch = tr->scratch;
/* if there is no tscrach, module_delta must be NULL. */
module_delta = READ_ONCE(tr->module_delta);
- if (!module_delta || tscratch->entries[0].mod_addr > addr)
- return addr + tr->text_delta;
+ if (!module_delta || tscratch->entries[0].mod_addr > addr) {
+ raddr = addr + tr->text_delta;
+ return is_kernel_core_data(raddr) || is_kernel_rodata(raddr) ||
+ __is_kernel(raddr) ? raddr : addr;
+ }
/* Note that entries must be sorted. */
nr_entries = tscratch->nr_entries;
--
2.47.2
next prev parent reply other threads:[~2025-03-25 21:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 21:38 [PATCH v2 0/4] tracing: Have function tracing and events handle module addresses Steven Rostedt
2025-03-25 21:38 ` [PATCH v2 1/4] tracing: Update function trace addresses with " Steven Rostedt
2025-03-25 21:38 ` [PATCH v2 2/4] tracing: Show function names when possible when listing fields Steven Rostedt
2025-03-25 21:38 ` Steven Rostedt [this message]
2025-03-25 21:38 ` [PATCH v2 4/4] tracing: Adjust addresses for printing out fields Steven Rostedt
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=20250325213919.790882670@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
/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