public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulus@samba.org, hpa@zytor.com,
	mingo@redhat.com, lizf@cn.fujitsu.com, penberg@cs.helsinki.fi,
	peterz@infradead.org, eduard.munteanu@linux360.ro,
	xiaoguangrong@cn.fujitsu.com, fweisbec@gmail.com,
	hirofumi@mail.parknet.co.jp, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perf/urgent] perf_event: Fix raw event processing
Date: Mon, 7 Dec 2009 05:31:02 GMT	[thread overview]
Message-ID: <tip-d8bd9e0aedabcb47887712497bc386a06ddcbd12@git.kernel.org> (raw)
In-Reply-To: <4B1C7F45.5080105@cn.fujitsu.com>

Commit-ID:  d8bd9e0aedabcb47887712497bc386a06ddcbd12
Gitweb:     http://git.kernel.org/tip/d8bd9e0aedabcb47887712497bc386a06ddcbd12
Author:     Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
AuthorDate: Mon, 7 Dec 2009 12:06:29 +0800
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 7 Dec 2009 06:26:24 +0100

perf_event: Fix raw event processing

We use 'data.raw_data' parameter to call process_raw_event(),
but data.raw_data buffer not include data size. it can make perf
tool crash.

This bug was introduced by commit 180f95e29a ("perf: Make common
SAMPLE_EVENT parser").

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4B1C7F45.5080105@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/builtin-kmem.c  |   11 ++++++++---
 tools/perf/builtin-sched.c |   11 ++++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index f218990..f84d7a3 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -289,13 +289,17 @@ static void process_free_event(struct raw_event_sample *raw,
 }
 
 static void
-process_raw_event(event_t *raw_event __used, void *more_data,
+process_raw_event(event_t *raw_event __used, u32 size, void *data,
 		  int cpu, u64 timestamp, struct thread *thread)
 {
-	struct raw_event_sample *raw = more_data;
+	struct raw_event_sample *raw;
 	struct event *event;
 	int type;
 
+	raw = malloc_or_die(sizeof(*raw)+size);
+	raw->size = size;
+	memcpy(raw->data, data, size);
+
 	type = trace_parse_common_type(raw->data);
 	event = trace_find_event(type);
 
@@ -345,7 +349,8 @@ static int process_sample_event(event_t *event)
 
 	dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
 
-	process_raw_event(event, data.raw_data, data.cpu, data.time, thread);
+	process_raw_event(event, data.raw_size, data.raw_data, data.cpu,
+			  data.time, thread);
 
 	return 0;
 }
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 7481ebd..4655e16 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1570,13 +1570,17 @@ process_sched_migrate_task_event(struct raw_event_sample *raw,
 }
 
 static void
-process_raw_event(event_t *raw_event __used, void *more_data,
+process_raw_event(event_t *raw_event __used, u32 size, void *data,
 		  int cpu, u64 timestamp, struct thread *thread)
 {
-	struct raw_event_sample *raw = more_data;
+	struct raw_event_sample *raw;
 	struct event *event;
 	int type;
 
+	raw = malloc_or_die(sizeof(*raw)+size);
+	raw->size = size;
+	memcpy(raw->data, data, size);
+
 	type = trace_parse_common_type(raw->data);
 	event = trace_find_event(type);
 
@@ -1629,7 +1633,8 @@ static int process_sample_event(event_t *event)
 	if (profile_cpu != -1 && profile_cpu != (int)data.cpu)
 		return 0;
 
-	process_raw_event(event, data.raw_data, data.cpu, data.time, thread);
+	process_raw_event(event, data.raw_size, data.raw_data, data.cpu,
+			  data.time, thread);
 
 	return 0;
 }

  parent reply	other threads:[~2009-12-07  5:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07  4:04 [PATCH 1/3] perf/sched: fix 'perf sched trace' Xiao Guangrong
2009-12-07  4:06 ` [PATCH 2/3] perf_event: fix for procing raw event Xiao Guangrong
2009-12-07  4:07   ` [PATCH 3/3] perf_event: fix __dsos__write_buildid_table() Xiao Guangrong
2009-12-07  5:19     ` OGAWA Hirofumi
2009-12-07  5:31     ` [tip:perf/urgent] perf_event: Fix __dsos__write_buildid_table() tip-bot for Xiao Guangrong
2009-12-07  4:54   ` [PATCH 2/3] perf_event: fix for procing raw event Xiao Guangrong
2009-12-07  5:04   ` [PATCH] perf_event: fix for processing raw event - fix Xiao Guangrong
2009-12-07  5:31     ` [tip:perf/urgent] perf_event: Eliminate raw->size tip-bot for Xiao Guangrong
2009-12-07  8:13       ` Peter Zijlstra
2009-12-07  8:30         ` Xiao Guangrong
2009-12-07  8:46           ` OGAWA Hirofumi
2009-12-07  6:33     ` [PATCH] perf_event: fix for processing raw event - fix OGAWA Hirofumi
2009-12-07  6:35       ` OGAWA Hirofumi
2009-12-07  5:31   ` tip-bot for Xiao Guangrong [this message]
2009-12-07  5:30 ` [tip:perf/urgent] perf/sched: Fix 'perf sched trace' tip-bot for Xiao Guangrong

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-d8bd9e0aedabcb47887712497bc386a06ddcbd12@git.kernel.org \
    --to=xiaoguangrong@cn.fujitsu.com \
    --cc=eduard.munteanu@linux360.ro \
    --cc=fweisbec@gmail.com \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --cc=penberg@cs.helsinki.fi \
    --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