* perf_counter: buffer overwrite problem for perf top command
@ 2009-05-10 6:13 Erdem Aktas
2009-05-10 6:22 ` Ingo Molnar
2009-05-10 6:24 ` [tip:perfcounters/core] perf_counter tools: fix " tip-bot for Erdem Aktas
0 siblings, 2 replies; 3+ messages in thread
From: Erdem Aktas @ 2009-05-10 6:13 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, Paul Mackerras, Corey Ashford, linux-kernel
Hi;
There is a buffer overwrite problem in builtin-top.c line 526, When I
tried to use ./perf top command, it was giving memory corruption
problem. should not we use malloc(strlen(str)+1) ?
Regards
-erdem
=======================
diff --git a/Documentation/perf_counter/builtin-top.c
b/Documentation/perf_counter/builtin-top.c
index cd6f61d..b1549dd 100644
--- a/Documentation/perf_counter/builtin-top.c
+++ b/Documentation/perf_counter/builtin-top.c
@@ -523,7 +523,7 @@ static int read_symbol(FILE *in, struct sym_entry *s)
if (strstr(sym, "_text_start") || strstr(sym, "_text_end"))
return 1;
- s->sym = malloc(strlen(str));
+ s->sym = malloc(strlen(str)+1);
assert(s->sym);
strcpy((char *)s->sym, str);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: perf_counter: buffer overwrite problem for perf top command
2009-05-10 6:13 perf_counter: buffer overwrite problem for perf top command Erdem Aktas
@ 2009-05-10 6:22 ` Ingo Molnar
2009-05-10 6:24 ` [tip:perfcounters/core] perf_counter tools: fix " tip-bot for Erdem Aktas
1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2009-05-10 6:22 UTC (permalink / raw)
To: Erdem Aktas; +Cc: Peter Zijlstra, Paul Mackerras, Corey Ashford, linux-kernel
* Erdem Aktas <eaktas1@gmail.com> wrote:
> Hi;
> There is a buffer overwrite problem in builtin-top.c line 526, When I
> tried to use ./perf top command, it was giving memory corruption
> problem. should not we use malloc(strlen(str)+1) ?
indeed, well spotted - we do an strcpy into that buffer so the \0 at
the end of the string has to be allocated too.
I've applied it to tip:perfcounters/core and tip/master and pushed
it out. Thanks,
Ingo
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:perfcounters/core] perf_counter tools: fix buffer overwrite problem for perf top command
2009-05-10 6:13 perf_counter: buffer overwrite problem for perf top command Erdem Aktas
2009-05-10 6:22 ` Ingo Molnar
@ 2009-05-10 6:24 ` tip-bot for Erdem Aktas
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Erdem Aktas @ 2009-05-10 6:24 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, eaktas1, hpa, mingo, tglx, mingo
Commit-ID: 82afae6016b672acb90ceb8e773bba0bd977d2a3
Gitweb: http://git.kernel.org/tip/82afae6016b672acb90ceb8e773bba0bd977d2a3
Author: Erdem Aktas <eaktas1@gmail.com>
AuthorDate: Sun, 10 May 2009 02:13:19 -0400
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Sun, 10 May 2009 08:21:18 +0200
perf_counter tools: fix buffer overwrite problem for perf top command
There is a buffer overwrite problem in builtin-top.c line 526, When I
tried to use ./perf top command, it was giving memory corruption
problem.
[ Impact: fix 'perf top' crash ]
LKML-Reference: <3fee128b0905092313x608e65e0l7b1116d86914114f@mail.gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
Documentation/perf_counter/builtin-top.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Documentation/perf_counter/builtin-top.c b/Documentation/perf_counter/builtin-top.c
index cd6f61d..b1549dd 100644
--- a/Documentation/perf_counter/builtin-top.c
+++ b/Documentation/perf_counter/builtin-top.c
@@ -523,7 +523,7 @@ static int read_symbol(FILE *in, struct sym_entry *s)
if (strstr(sym, "_text_start") || strstr(sym, "_text_end"))
return 1;
- s->sym = malloc(strlen(str));
+ s->sym = malloc(strlen(str)+1);
assert(s->sym);
strcpy((char *)s->sym, str);
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-10 6:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-10 6:13 perf_counter: buffer overwrite problem for perf top command Erdem Aktas
2009-05-10 6:22 ` Ingo Molnar
2009-05-10 6:24 ` [tip:perfcounters/core] perf_counter tools: fix " tip-bot for Erdem Aktas
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