From: tip-bot for Stephane Eranian <eranian@google.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org,
eranian@google.com, hpa@zytor.com, mingo@redhat.com,
peterz@infradead.org, dsahern@gmail.com, tglx@linutronix.de,
mingo@elte.hu
Subject: [tip:perf/core] perf tools: Fix strlen() bug in perf_event__synthesize_event_type()
Date: Tue, 31 Jan 2012 05:24:54 -0800 [thread overview]
Message-ID: <tip-d8d9c282a1abbe2baf6d22f959e6adf4c90629bf@git.kernel.org> (raw)
In-Reply-To: <20120120094912.GA4882@quad>
Commit-ID: d8d9c282a1abbe2baf6d22f959e6adf4c90629bf
Gitweb: http://git.kernel.org/tip/d8d9c282a1abbe2baf6d22f959e6adf4c90629bf
Author: Stephane Eranian <eranian@google.com>
AuthorDate: Fri, 20 Jan 2012 10:49:12 +0100
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 30 Jan 2012 22:29:12 -0200
perf tools: Fix strlen() bug in perf_event__synthesize_event_type()
The event_type record has a max length for the event name.
It's called MAX_EVENT_NAME.
The name may be truncated to fit the max length. But the header.size still
reflects the original name length. If that length is > MAX_EVENT_NAME, then the
header.size field is bogus. Fix this by using the length of the name after the
potential truncation.
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20120120094912.GA4882@quad
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
| 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 3e7e0b0..ecd7f4d 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2105,7 +2105,7 @@ int perf_event__synthesize_event_type(struct perf_tool *tool,
strncpy(ev.event_type.event_type.name, name, MAX_EVENT_NAME - 1);
ev.event_type.header.type = PERF_RECORD_HEADER_EVENT_TYPE;
- size = strlen(name);
+ size = strlen(ev.event_type.event_type.name);
size = ALIGN(size, sizeof(u64));
ev.event_type.header.size = sizeof(ev.event_type) -
(sizeof(ev.event_type.event_type.name) - size);
prev parent reply other threads:[~2012-01-31 13:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-20 9:49 [PATCH] perf: fix strlen() bug in perf_event__synthesize_event_type() (repost) Stephane Eranian
2012-01-26 13:36 ` [tip:perf/core] perf tools: Fix strlen() bug in perf_event__synthesize_event_type() tip-bot for Stephane Eranian
2012-01-31 13:24 ` tip-bot for Stephane Eranian [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=tip-d8d9c282a1abbe2baf6d22f959e6adf4c90629bf@git.kernel.org \
--to=eranian@google.com \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--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 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).