From: Tom Zanussi <zanussi@kernel.org>
To: rostedt@goodmis.org
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
Tom Zanussi <zanussi@kernel.org>
Subject: [PATCH v2 2/2] tracing: Remove size restriction on synthetic event cmd error logging
Date: Fri, 28 Jan 2022 14:08:27 -0600 [thread overview]
Message-ID: <0376692396a81d0b795127c66ea92ca5bf60f481.1643399022.git.zanussi@kernel.org> (raw)
In-Reply-To: <cover.1643399022.git.zanussi@kernel.org>
In-Reply-To: <cover.1643399022.git.zanussi@kernel.org>
Currently, synthetic event command error strings are restricted to a
length of MAX_FILTER_STR_VAL (256), which is too short for some
commands already seen in the wild (with cmd strings longer than that
showing up truncated in err_log).
Remove the restriction so that no synthetic event command error string
is ever truncated.
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
---
kernel/trace/trace_events_synth.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 149011e34ad9..d3d9cd677f9a 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -42,10 +42,13 @@ enum { ERRORS };
static const char *err_text[] = { ERRORS };
-static char last_cmd[MAX_FILTER_STR_VAL];
+static char *last_cmd;
static int errpos(const char *str)
{
+ if (!str || !last_cmd)
+ return 0;
+
return err_pos(last_cmd, str);
}
@@ -54,11 +57,19 @@ static void last_cmd_set(const char *str)
if (!str)
return;
- strncpy(last_cmd, str, MAX_FILTER_STR_VAL - 1);
+ kfree(last_cmd);
+ last_cmd = kzalloc(strlen(str) + 1, GFP_KERNEL);
+ if (!last_cmd)
+ return;
+
+ strncpy(last_cmd, str, strlen(str) + 1);
}
-static void synth_err(u8 err_type, u8 err_pos)
+static void synth_err(u8 err_type, u16 err_pos)
{
+ if (!last_cmd)
+ return;
+
tracing_log_err(NULL, "synthetic_events", last_cmd, err_text,
err_type, err_pos);
}
--
2.17.1
next prev parent reply other threads:[~2022-01-28 20:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 20:08 [PATCH v2 0/2] tracing: Misc bugfixes Tom Zanussi
2022-01-28 20:08 ` [PATCH v2 1/2] tracing: Remove size restriction on hist trigger cmd error logging Tom Zanussi
2022-01-28 20:08 ` Tom Zanussi [this message]
2022-01-28 21:42 ` [PATCH v2 0/2] tracing: Misc bugfixes Steven Rostedt
2022-01-28 21:50 ` Tom Zanussi
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=0376692396a81d0b795127c66ea92ca5bf60f481.1643399022.git.zanussi@kernel.org \
--to=zanussi@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@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
all inboxes | Powered by JetHome®