From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
stable@kernel.org
Subject: [PATCH 2/2] function-graph: always initialize task ret_stack
Date: Tue, 02 Jun 2009 18:02:14 -0400 [thread overview]
Message-ID: <20090602220309.764167406@goodmis.org> (raw)
In-Reply-To: 20090602220212.894951549@goodmis.org
[-- Attachment #1: 0002-function-graph-always-initialize-task-ret_stack.patch --]
[-- Type: text/plain, Size: 1341 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
On creating a new task while running the function graph tracer, if
we fail to allocate the ret_stack, and then fail the fork, the
code will free the parent ret_stack. This is because the child
duplicated the parent and currently points to the parent's ret_stack.
This patch always initializes the task's ret_stack to NULL.
[ Impact: prevent crash of parent on low memory during fork ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ftrace.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1664d3f..bb081f3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2738,6 +2738,9 @@ void unregister_ftrace_graph(void)
/* Allocate a return stack for newly created task */
void ftrace_graph_init_task(struct task_struct *t)
{
+ /* Make sure we do not use the parent ret_stack */
+ t->ret_stack = NULL;
+
if (atomic_read(&ftrace_graph_active)) {
struct ftrace_ret_stack *ret_stack;
@@ -2753,8 +2756,7 @@ void ftrace_graph_init_task(struct task_struct *t)
/* make curr_ret_stack visable before we add the ret_stack */
smp_wmb();
t->ret_stack = ret_stack;
- } else
- t->ret_stack = NULL;
+ }
}
void ftrace_graph_exit_task(struct task_struct *t)
--
1.6.3.1
--
next prev parent reply other threads:[~2009-06-02 22:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-02 22:02 [PATCH 0/2] [GIT PULL][urgent] function-graph: allocation and freeing of ret_stack Steven Rostedt
2009-06-02 22:02 ` [PATCH 1/2] function-graph: move initialization of new tasks up in fork Steven Rostedt
2009-06-02 22:24 ` Frederic Weisbecker
2009-06-02 22:02 ` Steven Rostedt [this message]
2009-06-07 9:51 ` [PATCH 0/2] [GIT PULL][urgent] function-graph: allocation and freeing of ret_stack Ingo Molnar
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=20090602220309.764167406@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=stable@kernel.org \
/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