public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Masami Hiramatsu <mhiramat@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@redhat.com, peterz@infradead.org, fweisbec@gmail.com,
	rostedt@goodmis.org, ak@linux.intel.com, jbaron@redhat.com,
	tglx@linutronix.de, laijs@cn.fujitsu.com, mhiramat@redhat.com,
	linux-kernel@vger.kernel.org, hpa@zytor.com, fche@redhat.com,
	jkenisto@us.ibm.com, tzanussi@gmail.com, lizf@cn.fujitsu.com,
	hch@infradead.org, ananth@in.ibm.com, srikar@linux.vnet.ibm.com,
	mingo@elte.hu, prasad@linux.vnet.ibm.com
Subject: [tip:perf/probes] tracing/kprobes: Fix profiling alignment for perf_counter buffer
Date: Sat, 17 Oct 2009 10:01:41 GMT	[thread overview]
Message-ID: <tip-74ebb63e7cd25f6fb02a45fc2ea7735bce1217c9@git.kernel.org> (raw)
In-Reply-To: <20090914204928.18779.60029.stgit@dhcp-100-2-132.bos.redhat.com>

Commit-ID:  74ebb63e7cd25f6fb02a45fc2ea7735bce1217c9
Gitweb:     http://git.kernel.org/tip/74ebb63e7cd25f6fb02a45fc2ea7735bce1217c9
Author:     Masami Hiramatsu <mhiramat@redhat.com>
AuthorDate: Mon, 14 Sep 2009 16:49:28 -0400
Committer:  Frederic Weisbecker <fweisbec@gmail.com>
CommitDate: Thu, 17 Sep 2009 04:03:57 +0200

tracing/kprobes: Fix profiling alignment for perf_counter buffer

Fix *probe_profile_func() to align buffer size, since perf_counter
requires its buffer entries to be 8 bytes aligned.

Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Frank Ch. Eigler <fche@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jason Baron <jbaron@redhat.com>
Cc: K.Prasad <prasad@linux.vnet.ibm.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20090914204928.18779.60029.stgit@dhcp-100-2-132.bos.redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
---
 kernel/trace/trace_kprobe.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 70b632c..d8db935 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1149,18 +1149,23 @@ static __kprobes int kprobe_profile_func(struct kprobe *kp,
 	struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kprobe_trace_entry *entry;
-	int size, i, pc;
+	int size, __size, i, pc;
 	unsigned long irq_flags;
 
 	local_save_flags(irq_flags);
 	pc = preempt_count();
 
-	size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args);
+	__size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args);
+	size = ALIGN(__size + sizeof(u32), sizeof(u64));
+	size -= sizeof(u32);
 
 	do {
 		char raw_data[size];
 		struct trace_entry *ent;
-
+		/*
+		 * Zero dead bytes from alignment to avoid stack leak
+		 * to userspace
+		 */
 		*(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
 		entry = (struct kprobe_trace_entry *)raw_data;
 		ent = &entry->ent;
@@ -1183,13 +1188,15 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri,
 	struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
 	struct ftrace_event_call *call = &tp->call;
 	struct kretprobe_trace_entry *entry;
-	int size, i, pc;
+	int size, __size, i, pc;
 	unsigned long irq_flags;
 
 	local_save_flags(irq_flags);
 	pc = preempt_count();
 
-	size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args);
+	__size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args);
+	size = ALIGN(__size + sizeof(u32), sizeof(u64));
+	size -= sizeof(u32);
 
 	do {
 		char raw_data[size];

  reply	other threads:[~2009-10-17 10:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-14 20:48 [PATCH tracing/kprobes 0/6] tracing/kprobes: kprobe-based event tracer update and perf support Masami Hiramatsu
2009-09-14 20:48 ` [PATCH tracing/kprobes 1/6] tracing/kprobes: Fix trace_probe registration order Masami Hiramatsu
2009-10-17 10:00   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 2/6] ftrace: Fix trace_add_event_call() to initialize list Masami Hiramatsu
2009-09-15 23:51   ` Steven Rostedt
2009-09-16 14:17     ` Masami Hiramatsu
2009-09-16 14:29       ` Steven Rostedt
2009-09-16 15:42         ` [PATCH tracing/kprobes 2/6] ftrace: Fix trace_add_event_call() to initialize list take 2 Masami Hiramatsu
2009-09-16 15:43           ` Steven Rostedt
2009-10-17 10:01           ` [tip:perf/probes] ftrace: Fix trace_add_event_call() to initialize list tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 3/6] ftrace: Fix trace_remove_event_call() to lock trace_event_mutex Masami Hiramatsu
2009-09-16  3:17   ` Steven Rostedt
2009-09-16  4:05     ` Frederic Weisbecker
2009-09-16  4:54       ` Ananth N Mavinakayanahalli
2009-09-16  5:33         ` Frederic Weisbecker
2009-09-16 14:31     ` Masami Hiramatsu
2009-10-17 10:01   ` [tip:perf/probes] " tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 4/6] tracing/kprobes: Add probe handler dispatcher for support perf and ftrace Masami Hiramatsu
2009-10-17 10:01   ` [tip:perf/probes] tracing/kprobes: Add probe handler dispatcher to support perf and ftrace concurrent use tip-bot for Masami Hiramatsu
2009-09-14 20:49 ` [PATCH tracing/kprobes 5/6] tracing/kprobes: Fix profiling alignment for perf_counter buffer Masami Hiramatsu
2009-10-17 10:01   ` tip-bot for Masami Hiramatsu [this message]
2009-09-14 20:49 ` [PATCH tracing/kprobes 6/6] tracing/kprobes: Disable kprobe events by default Masami Hiramatsu
2009-10-17 10:01   ` [tip:perf/probes] tracing/kprobes: Disable kprobe events by default after creation tip-bot for Masami Hiramatsu
2009-09-17  2:39 ` [PATCH tracing/kprobes 0/6] tracing/kprobes: kprobe-based event tracer update and perf support Frederic Weisbecker
2009-09-17 17:32   ` Masami Hiramatsu

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-74ebb63e7cd25f6fb02a45fc2ea7735bce1217c9@git.kernel.org \
    --to=mhiramat@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=ananth@in.ibm.com \
    --cc=fche@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=jbaron@redhat.com \
    --cc=jkenisto@us.ibm.com \
    --cc=laijs@cn.fujitsu.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=peterz@infradead.org \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=tzanussi@gmail.com \
    /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