aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_kprobe.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-09-14 16:49:28 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-09-16 22:03:57 -0400
commit74ebb63e7cd25f6fb02a45fc2ea7735bce1217c9 (patch)
treea7d5b62b75f261ad14860d2993eec23697629e73 /kernel/trace/trace_kprobe.c
parent50d780560785b068c358675c5f0bf6c83b5c373e (diff)
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>
Diffstat (limited to 'kernel/trace/trace_kprobe.c')
-rw-r--r--kernel/trace/trace_kprobe.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 70b632c3bd08..d8db9357489b 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,
1149 struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp); 1149 struct trace_probe *tp = container_of(kp, struct trace_probe, rp.kp);
1150 struct ftrace_event_call *call = &tp->call; 1150 struct ftrace_event_call *call = &tp->call;
1151 struct kprobe_trace_entry *entry; 1151 struct kprobe_trace_entry *entry;
1152 int size, i, pc; 1152 int size, __size, i, pc;
1153 unsigned long irq_flags; 1153 unsigned long irq_flags;
1154 1154
1155 local_save_flags(irq_flags); 1155 local_save_flags(irq_flags);
1156 pc = preempt_count(); 1156 pc = preempt_count();
1157 1157
1158 size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args); 1158 __size = SIZEOF_KPROBE_TRACE_ENTRY(tp->nr_args);
1159 size = ALIGN(__size + sizeof(u32), sizeof(u64));
1160 size -= sizeof(u32);
1159 1161
1160 do { 1162 do {
1161 char raw_data[size]; 1163 char raw_data[size];
1162 struct trace_entry *ent; 1164 struct trace_entry *ent;
1163 1165 /*
1166 * Zero dead bytes from alignment to avoid stack leak
1167 * to userspace
1168 */
1164 *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL; 1169 *(u64 *)(&raw_data[size - sizeof(u64)]) = 0ULL;
1165 entry = (struct kprobe_trace_entry *)raw_data; 1170 entry = (struct kprobe_trace_entry *)raw_data;
1166 ent = &entry->ent; 1171 ent = &entry->ent;
@@ -1183,13 +1188,15 @@ static __kprobes int kretprobe_profile_func(struct kretprobe_instance *ri,
1183 struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp); 1188 struct trace_probe *tp = container_of(ri->rp, struct trace_probe, rp);
1184 struct ftrace_event_call *call = &tp->call; 1189 struct ftrace_event_call *call = &tp->call;
1185 struct kretprobe_trace_entry *entry; 1190 struct kretprobe_trace_entry *entry;
1186 int size, i, pc; 1191 int size, __size, i, pc;
1187 unsigned long irq_flags; 1192 unsigned long irq_flags;
1188 1193
1189 local_save_flags(irq_flags); 1194 local_save_flags(irq_flags);
1190 pc = preempt_count(); 1195 pc = preempt_count();
1191 1196
1192 size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args); 1197 __size = SIZEOF_KRETPROBE_TRACE_ENTRY(tp->nr_args);
1198 size = ALIGN(__size + sizeof(u32), sizeof(u64));
1199 size -= sizeof(u32);
1193 1200
1194 do { 1201 do {
1195 char raw_data[size]; 1202 char raw_data[size];