From: tip-bot for Frederic Weisbecker <fweisbec@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com,
mingo@redhat.com, efault@gmx.de, peterz@infradead.org,
fweisbec@gmail.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perfcounters/urgent] perf_counter: Zero dead bytes from ftrace raw samples size alignment
Date: Mon, 10 Aug 2009 18:01:24 GMT [thread overview]
Message-ID: <tip-1853db0e02ae4088f102b0d8e59e83dc98f93f03@git.kernel.org> (raw)
In-Reply-To: <1249915116-5210-1-git-send-email-fweisbec@gmail.com>
Commit-ID: 1853db0e02ae4088f102b0d8e59e83dc98f93f03
Gitweb: http://git.kernel.org/tip/1853db0e02ae4088f102b0d8e59e83dc98f93f03
Author: Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Mon, 10 Aug 2009 16:38:36 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Mon, 10 Aug 2009 16:51:19 +0200
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>
---
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 a05524f..f64fbaa 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -648,6 +648,9 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
* char raw_data[__entry_size]; <- allocate our sample in the stack
* struct trace_entry *ent;
*
+ * zero dead bytes from alignment to avoid stack leak to userspace:
+ *
+ * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
* entry = (struct ftrace_raw_<call> *)raw_data;
* ent = &entry->ent;
* tracing_generic_entry_update(ent, irq_flags, pc);
@@ -698,6 +701,7 @@ static void ftrace_profile_##call(proto) \
char raw_data[__entry_size]; \
struct trace_entry *ent; \
\
+ *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; \
entry = (struct ftrace_raw_##call *)raw_data; \
ent = &entry->ent; \
tracing_generic_entry_update(ent, irq_flags, pc); \
next prev parent reply other threads:[~2009-08-10 18:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-08 2:26 [PATCH 1/4] perf tools: callchain: Warn only once in empty node detection Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 1/3] perfcounter: Initialize tracepoint record before any use Frederic Weisbecker
2009-08-08 2:30 ` Frederic Weisbecker
2009-08-10 9:27 ` [PATCH 4/3] perf_counter: Correct PERF_SAMPLE_RAW output Peter Zijlstra
2009-08-10 9:36 ` [tip:perfcounters/urgent] " tip-bot for Peter Zijlstra
2009-08-10 9:48 ` [PATCH 4/3] " Frederic Weisbecker
2009-08-10 12:57 ` Frederic Weisbecker
2009-08-10 13:06 ` Peter Zijlstra
2009-08-10 14:11 ` [PATCH 6/3] perfcounter: Substract the buffer size field from the event record size Frederic Weisbecker
2009-08-10 14:13 ` Peter Zijlstra
2009-08-10 14:21 ` [tip:perfcounters/urgent] perf_counter: Subtract " tip-bot for Frederic Weisbecker
2009-08-10 9:27 ` [PATCH 5/3] perf_counter: Require CAP_SYS_ADMIN for raw tracepoint data Peter Zijlstra
2009-08-10 9:36 ` [tip:perfcounters/urgent] " tip-bot for Peter Zijlstra
2009-08-08 2:26 ` [PATCH 2/4] perf tools: callchain: Ignore empty callchains Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 2/3] perfcounter: Generalize the tracepoint sampling to generic sampling Frederic Weisbecker
2009-08-08 11:52 ` [tip:perfcounters/core] perf_counter: Fix tracepoint sampling to be part of " tip-bot for Frederic Weisbecker
2009-08-09 11:10 ` tip-bot for Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 3/4] perf tools: callchain: Default display callchain from report if recorded with -g Frederic Weisbecker
2009-08-08 2:26 ` [PATCH 3/3] perfcounter: Align ftrace events raw samples to 8 bytes Frederic Weisbecker
2009-08-08 11:52 ` [tip:perfcounters/core] perf_counter: Fix ftrace events raw samples to be aligned " tip-bot for Frederic Weisbecker
2009-08-10 7:13 ` [PATCH 3/3] perfcounter: Align ftrace events raw samples " Peter Zijlstra
2009-08-10 7:32 ` Frederic Weisbecker
2009-08-10 14:38 ` [PATCH 7/3] perfcounter: Zeroe dead bytes from ftrace raw samples size alignment Frederic Weisbecker
2009-08-10 18:01 ` tip-bot for Frederic Weisbecker [this message]
2009-08-08 2:26 ` [PATCH 4/4] perf tools: callchain: Display amount of ignored chains in fractal mode Frederic Weisbecker
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-1853db0e02ae4088f102b0d8e59e83dc98f93f03@git.kernel.org \
--to=fweisbec@gmail.com \
--cc=acme@redhat.com \
--cc=efault@gmx.de \
--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