* [GIT PULL] tracing: Fix misuse of strncpy to copy boot params
@ 2009-10-14 20:38 Frederic Weisbecker
2009-10-15 2:01 ` Li Zefan
0 siblings, 1 reply; 3+ messages in thread
From: Frederic Weisbecker @ 2009-10-14 20:38 UTC (permalink / raw)
To: Ingo Molnar; +Cc: LKML, Frederic Weisbecker, Steven Rostedt, Li Zefan
Ingo,
Please pull this fixlet for .32 that can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
tracing/fixes
Frederic Weisbecker (1):
tracing: Fix misuse of strncpy to copy boot params
kernel/trace/ftrace.c | 4 ++--
kernel/trace/trace.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
>From f44bec1286f516d921210a1bf843725f5d4b86ef Mon Sep 17 00:00:00 2001
From: Frederic Weisbecker <fweisbec@gmail.com>
Date: Wed, 14 Oct 2009 21:17:00 +0200
Subject: [PATCH] tracing: Fix misuse of strncpy to copy boot params
While copying ftrace string boot parameters into buffers, we
use strncpy by passing the whole buffer size instead of the max
strlen the buffers can host (which is buffer size - 1), this might
lead to non-null terminated strings.
Fix that by simply using strlcpy instead.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
---
kernel/trace/ftrace.c | 4 ++--
kernel/trace/trace.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 37ba67e..0f4803f 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2300,14 +2300,14 @@ static char ftrace_filter_buf[FTRACE_FILTER_SIZE] __initdata;
static int __init set_ftrace_notrace(char *str)
{
- strncpy(ftrace_notrace_buf, str, FTRACE_FILTER_SIZE);
+ strlcpy(ftrace_notrace_buf, str, FTRACE_FILTER_SIZE);
return 1;
}
__setup("ftrace_notrace=", set_ftrace_notrace);
static int __init set_ftrace_filter(char *str)
{
- strncpy(ftrace_filter_buf, str, FTRACE_FILTER_SIZE);
+ strlcpy(ftrace_filter_buf, str, FTRACE_FILTER_SIZE);
return 1;
}
__setup("ftrace_filter=", set_ftrace_filter);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 4506826..621d81e 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -131,7 +131,7 @@ static char *default_bootup_tracer;
static int __init set_ftrace(char *str)
{
- strncpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
+ strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
default_bootup_tracer = bootup_tracer_buf;
/* We are using ftrace early, expand it */
ring_buffer_expanded = 1;
--
1.6.2.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [GIT PULL] tracing: Fix misuse of strncpy to copy boot params
2009-10-14 20:38 [GIT PULL] tracing: Fix misuse of strncpy to copy boot params Frederic Weisbecker
@ 2009-10-15 2:01 ` Li Zefan
2009-10-15 12:32 ` Frederic Weisbecker
0 siblings, 1 reply; 3+ messages in thread
From: Li Zefan @ 2009-10-15 2:01 UTC (permalink / raw)
To: Frederic Weisbecker; +Cc: Ingo Molnar, LKML, Steven Rostedt
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 4506826..621d81e 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -131,7 +131,7 @@ static char *default_bootup_tracer;
>
> static int __init set_ftrace(char *str)
> {
> - strncpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
> + strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
Actually using strncpy() here is fine.
See how the str buf is used:
int register_tracer(struct tracer *type)
{
...
if (strncmp(default_bootup_tracer, type->name, MAX_TRACER_SIZE))
...
}
> default_bootup_tracer = bootup_tracer_buf;
> /* We are using ftrace early, expand it */
> ring_buffer_expanded = 1;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [GIT PULL] tracing: Fix misuse of strncpy to copy boot params
2009-10-15 2:01 ` Li Zefan
@ 2009-10-15 12:32 ` Frederic Weisbecker
0 siblings, 0 replies; 3+ messages in thread
From: Frederic Weisbecker @ 2009-10-15 12:32 UTC (permalink / raw)
To: Li Zefan; +Cc: Ingo Molnar, LKML, Steven Rostedt
On Thu, Oct 15, 2009 at 10:01:13AM +0800, Li Zefan wrote:
> > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> > index 4506826..621d81e 100644
> > --- a/kernel/trace/trace.c
> > +++ b/kernel/trace/trace.c
> > @@ -131,7 +131,7 @@ static char *default_bootup_tracer;
> >
> > static int __init set_ftrace(char *str)
> > {
> > - strncpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
> > + strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
>
> Actually using strncpy() here is fine.
>
> See how the str buf is used:
>
> int register_tracer(struct tracer *type)
> {
> ...
> if (strncmp(default_bootup_tracer, type->name, MAX_TRACER_SIZE))
> ...
> }
Yeah. I can remove the change for this buffer and send
another pull request.
Thanks.
> > default_bootup_tracer = bootup_tracer_buf;
> > /* We are using ftrace early, expand it */
> > ring_buffer_expanded = 1;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-15 12:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-14 20:38 [GIT PULL] tracing: Fix misuse of strncpy to copy boot params Frederic Weisbecker
2009-10-15 2:01 ` Li Zefan
2009-10-15 12:32 ` Frederic Weisbecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox