diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-08-10 10:38:36 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-10 10:51:19 -0400 |
commit | 1853db0e02ae4088f102b0d8e59e83dc98f93f03 (patch) | |
tree | 9fd877538baf1904a31eb5436536954cdced5293 /include/trace | |
parent | 304703aba31a87903b8c0db8f5e6890cac2d596d (diff) |
perf_counter: Zero dead bytes from ftrace raw samples size alignment
After aligning the ftrace raw samples, there are dead bytes storing
random data from the stack. We don't want to leak these to userspace,
then zero these out.
Before:
0x2de88 [0x50]: event: 9
.
. ... raw event: size 80 bytes
. 0000: 09 00 00 00 01 00 50 00 d0 c7 00 81 ff ff ff ff ......P........
. 0010: 68 01 00 00 68 01 00 00 2c 00 00 00 00 00 00 00 h...h...,......
. 0020: 2c 00 00 00 2b 00 01 02 68 01 00 00 68 01 00 00 ,...+...h...h..
. 0030: 6b 6f 6e 64 65 6d 61 6e 64 2f 30 00 00 00 00 00 kondemand/0....
. 0040: 68 01 00 00 40 7f 46 81 ff ff ff ff 00 10 1b 7f h...@.F........
^ ^ ^ ^
Leak
After:
0x2d318 [0x50]: event: 9
.
. ... raw event: size 80 bytes
. 0000: 09 00 00 00 01 00 50 00 d0 c7 00 81 ff ff ff ff ......P........
. 0010: 68 01 00 00 68 01 00 00 68 14 00 00 00 00 00 00 h...h...h......
. 0020: 2c 00 00 00 2b 00 01 02 68 01 00 00 68 01 00 00 ,...+...h...h..
. 0030: 6b 6f 6e 64 65 6d 61 6e 64 2f 30 00 00 00 00 00 kondemand/0....
. 0040: 68 01 00 00 a0 80 46 81 ff ff ff ff 00 00 00 00 h.....F........
^ ^ ^ ^
Fixed
Reported-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1249915116-5210-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Diffstat (limited to 'include/trace')
-rw-r--r-- | include/trace/ftrace.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h index a05524fa245d..f64fbaae781a 100644 --- a/include/trace/ftrace.h +++ b/include/trace/ftrace.h | |||
@@ -648,6 +648,9 @@ __attribute__((section("_ftrace_events"))) event_##call = { \ | |||
648 | * char raw_data[__entry_size]; <- allocate our sample in the stack | 648 | * char raw_data[__entry_size]; <- allocate our sample in the stack |
649 | * struct trace_entry *ent; | 649 | * struct trace_entry *ent; |
650 | * | 650 | * |
651 | * zero dead bytes from alignment to avoid stack leak to userspace: | ||
652 | * | ||
653 | * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; | ||
651 | * entry = (struct ftrace_raw_<call> *)raw_data; | 654 | * entry = (struct ftrace_raw_<call> *)raw_data; |
652 | * ent = &entry->ent; | 655 | * ent = &entry->ent; |
653 | * tracing_generic_entry_update(ent, irq_flags, pc); | 656 | * tracing_generic_entry_update(ent, irq_flags, pc); |
@@ -698,6 +701,7 @@ static void ftrace_profile_##call(proto) \ | |||
698 | char raw_data[__entry_size]; \ | 701 | char raw_data[__entry_size]; \ |
699 | struct trace_entry *ent; \ | 702 | struct trace_entry *ent; \ |
700 | \ | 703 | \ |
704 | *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; \ | ||
701 | entry = (struct ftrace_raw_##call *)raw_data; \ | 705 | entry = (struct ftrace_raw_##call *)raw_data; \ |
702 | ent = &entry->ent; \ | 706 | ent = &entry->ent; \ |
703 | tracing_generic_entry_update(ent, irq_flags, pc); \ | 707 | tracing_generic_entry_update(ent, irq_flags, pc); \ |