From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>,
Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: Re: [PATCH] tracing: Add size check when printing trace_marker output
Date: Tue, 12 Dec 2023 22:10:10 -0500 [thread overview]
Message-ID: <20231212221010.70c84d2d@gandalf.local.home> (raw)
In-Reply-To: <20231212084444.4619b8ce@gandalf.local.home>
On Tue, 12 Dec 2023 08:44:44 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
>
> If for some reason the trace_marker write does not have a nul byte for the
> string, it will overflow the print:
>
> trace_seq_printf(s, ": %s", field->buf);
>
> The field->buf could be missing the nul byte. To prevent overflow, add the
> max size that the buf can be by using the event size and the field
> location.
>
> int max = iter->ent_size - offsetof(struct print_entry, buf);
>
> trace_seq_printf(s, ": %*s", max, field->buf);
Bah, this needs to be:
trace_seq_printf(s, ": %.*s", max, field->buf);
Note the '.' between % and *. Otherwise it right aligns the output.
This did fail the selftest for trace_printk(), but I modified the new one
to add " *" to accommodate it :-p
Sending out v2.
-- Steve
prev parent reply other threads:[~2023-12-13 3:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 13:44 [PATCH] tracing: Add size check when printing trace_marker output Steven Rostedt
2023-12-12 14:23 ` Mathieu Desnoyers
2023-12-12 15:28 ` Steven Rostedt
2023-12-12 22:47 ` Masami Hiramatsu
2023-12-13 3:10 ` Steven Rostedt [this message]
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=20231212221010.70c84d2d@gandalf.local.home \
--to=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).