From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Frederic Weisbecker <fweisbec@gmail.com>,
Chase Douglas <chase.douglas@canonical.com>
Subject: [PATCH 8/9] tracing/function-graph: Use correct string size for snprintf
Date: Mon, 28 Jun 2010 23:08:44 -0400 [thread overview]
Message-ID: <20100629031044.693053496@goodmis.org> (raw)
In-Reply-To: 20100629030836.222433712@goodmis.org
[-- Attachment #1: 0008-tracing-function-graph-Use-correct-string-size-for-s.patch --]
[-- Type: text/plain, Size: 1498 bytes --]
From: Chase Douglas <chase.douglas@canonical.com>
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 value for the string format "%03lu" can not be
larger than 1000. However, this change makes it correct. By making the
size correct we guard against potential future changes that could actually
cause a buffer overrun.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
LKML-Reference: <1276619355-18116-1-git-send-email-chase.douglas@canonical.com>
[ added 'UL' to number 8 to fix gcc warning comparing it to sizeof() ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
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..6bff236 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), 8UL - len), "%03lu",
+ nsecs_rem);
ret = trace_seq_printf(s, ".%s", nsecs_str);
if (!ret)
return TRACE_TYPE_PARTIAL_LINE;
--
1.7.1
next prev parent reply other threads:[~2010-06-29 3:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-29 3:08 [PATCH 0/9] [GI PULL][2.6.36] tracing: various updates Steven Rostedt
2010-06-29 3:08 ` [PATCH 1/9] tracing: Use a global field list for all syscall exit events Steven Rostedt
2010-06-29 3:08 ` [PATCH 2/9] tracing: Dont allocate common fields for every trace events Steven Rostedt
2010-06-29 3:08 ` [PATCH 3/9] tracing: Convert some timer events to DEFINE_EVENT Steven Rostedt
2010-06-29 3:08 ` [PATCH 4/9] tracing: Convert more sched " Steven Rostedt
2010-06-29 3:08 ` [PATCH 5/9] tracing: Remove test of NULL define_fields callback Steven Rostedt
2010-06-29 3:08 ` [PATCH 6/9] tracing: Remove redundant raw_init callbacks Steven Rostedt
2010-06-29 3:08 ` [PATCH 7/9] tracing: Remove open-coded __trace_add_event_call() Steven Rostedt
2010-06-29 3:08 ` Steven Rostedt [this message]
2010-06-29 3:08 ` [PATCH 9/9] tracing: Use class->reg() for all registering of events Steven Rostedt
2010-06-29 8:42 ` [PATCH 0/9] [GI PULL][2.6.36] tracing: various updates Ingo Molnar
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=20100629031044.693053496@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=chase.douglas@canonical.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.