From: Steven Rostedt <rostedt@goodmis.org>
To: Chase Douglas <chase.douglas@canonical.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>,
Tejun Heo <tj@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing: use correct string size for snprintf
Date: Tue, 15 Jun 2010 16:52:35 -0400 [thread overview]
Message-ID: <1276635155.3556.26.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <1276619355-18116-1-git-send-email-chase.douglas@canonical.com>
On Tue, 2010-06-15 at 12:29 -0400, Chase Douglas wrote:
> The nsecs_str string is a local variable defined as:
>
> char nsecs_str[5];
>
> It is possible for the snprintf call to use a size value larger than the
> size of the string. This should not cause a buffer overrun as it is
> written now due to the maximum size of the string format. However, this
> change makes it correct. By making the size correct we guard against
> potential future changes that could actually cause a buffer overrun.
>
> Cc: stable@kernel.org
I see that because nsecs_str is based off of nsecs_rem which is the
remainder of a division of a 1000, that it wont ever be more than 4 in
length. For this, I'll remove the "Cc: stable" part and queue it for 36.
No urgent need for now.
But I still think it should be added, just because it looks to fragile
to have what is in the kernel now.
Thanks!
-- Steve
> Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
> ---
> kernel/trace/trace_functions_graph.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
> index 79f4bac..73d6bd1 100644
> --- a/kernel/trace/trace_functions_graph.c
> +++ b/kernel/trace/trace_functions_graph.c
> @@ -641,7 +641,8 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
>
> /* Print nsecs (we don't want to exceed 7 numbers) */
> if (len < 7) {
> - snprintf(nsecs_str, 8 - len, "%03lu", nsecs_rem);
> + snprintf(nsecs_str, min(sizeof(nsecs_str), 8 - len), "%03lu",
> + nsecs_rem);
> ret = trace_seq_printf(s, ".%s", nsecs_str);
> if (!ret)
> return TRACE_TYPE_PARTIAL_LINE;
next prev parent reply other threads:[~2010-06-15 20:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-15 16:29 Chase Douglas
2010-06-15 20:52 ` Steven Rostedt [this message]
2010-06-29 9:24 ` [tip:perf/core] tracing/function-graph: Use " tip-bot for Chase Douglas
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=1276635155.3556.26.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=chase.douglas@canonical.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tj@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
Powered by JetHome