From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Dan Carpenter <dan.carpenter@linaro.org>,
linux-trace-kernel@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: [PATCH v5 3/5] tracing/probes: Fix to update dynamic data counter if fetcharg uses it
Date: Tue, 11 Jul 2023 23:15:48 +0900 [thread overview]
Message-ID: <168908494781.123124.8160245359962103684.stgit@devnote2> (raw)
In-Reply-To: <168908491977.123124.16583481716284477889.stgit@devnote2>
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Fix to update dynamic data counter ('dyndata') and max length ('maxlen')
only if the fetcharg uses the dynamic data. Also get out arg->dynamic
from unlikely(). This makes dynamic data address wrong if
process_fetch_insn() returns error on !arg->dynamic case.
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Link: https://lore.kernel.org/all/20230710233400.5aaf024e@gandalf.local.home/
Fixes: 9178412ddf5a ("tracing: probeevent: Return consumed bytes of dynamic area")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
kernel/trace/trace_probe_tmpl.h | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/kernel/trace/trace_probe_tmpl.h b/kernel/trace/trace_probe_tmpl.h
index ed9d57c6b041..185da001f4c3 100644
--- a/kernel/trace/trace_probe_tmpl.h
+++ b/kernel/trace/trace_probe_tmpl.h
@@ -267,11 +267,13 @@ store_trace_args(void *data, struct trace_probe *tp, void *rec,
if (unlikely(arg->dynamic))
*dl = make_data_loc(maxlen, dyndata - base);
ret = process_fetch_insn(arg->code, rec, dl, base);
- if (unlikely(ret < 0 && arg->dynamic)) {
- *dl = make_data_loc(0, dyndata - base);
- } else {
- dyndata += ret;
- maxlen -= ret;
+ if (arg->dynamic) {
+ if (unlikely(ret < 0)) {
+ *dl = make_data_loc(0, dyndata - base);
+ } else {
+ dyndata += ret;
+ maxlen -= ret;
+ }
}
}
}
next prev parent reply other threads:[~2023-07-11 14:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-11 14:15 [PATCH v5 0/5] tracing/probes: Fix bugs in process_fetch_insn Masami Hiramatsu (Google)
2023-07-11 14:15 ` [PATCH v5 1/5] tracing/probes: Fix to avoid double count of the string length on the array Masami Hiramatsu (Google)
2023-07-11 14:15 ` [PATCH v5 2/5] tracing/probes: Fix not to count error code to total length Masami Hiramatsu (Google)
2023-07-11 14:15 ` Masami Hiramatsu (Google) [this message]
2023-07-13 13:34 ` [PATCH v5 3/5] tracing/probes: Fix to update dynamic data counter if fetcharg uses it Steven Rostedt
2023-07-13 14:34 ` Masami Hiramatsu
2023-07-11 14:15 ` [PATCH v5 4/5] Revert "tracing: Add "(fault)" name injection to kernel probes" Masami Hiramatsu (Google)
2023-07-11 16:19 ` Steven Rostedt
2023-07-11 14:16 ` [PATCH v5 5/5] tracing/probes: Fix to record 0-length data_loc in fetch_store_string*() if fails Masami Hiramatsu (Google)
2023-07-11 16:22 ` 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=168908494781.123124.8160245359962103684.stgit@devnote2 \
--to=mhiramat@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).