public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Namhyung Kim <namhyung@kernel.org>
Subject: [for-next][PATCH 5/8] ftrace: Have set_graph_functions handle write with RDWR
Date: Fri, 03 Feb 2017 08:40:38 -0500	[thread overview]
Message-ID: <20170203134137.445198321@goodmis.org> (raw)
In-Reply-To: 20170203134033.087760237@goodmis.org

[-- Attachment #1: 0005-ftrace-Have-set_graph_functions-handle-write-with-RD.patch --]
[-- Type: text/plain, Size: 1181 bytes --]

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Since reading the set_graph_functions uses seq functions, which sets the
file->private_data pointer to a seq_file descriptor. On writes the
ftrace_graph_data descriptor is set to file->private_data. But if the file
is opened for RDWR, the ftrace_graph_write() will incorrectly use the
file->private_data descriptor instead of
((struct seq_file *)file->private_data)->private pointer, and this can crash
the kernel.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b7df0dcf8652..0233c8cb45f4 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4842,6 +4842,12 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
 	if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX))
 		return -ENOMEM;
 
+	/* Read mode uses seq functions */
+	if (file->f_mode & FMODE_READ) {
+		struct seq_file *m = file->private_data;
+		fgd = m->private;
+	}
+
 	read = trace_get_user(&parser, ubuf, cnt, ppos);
 
 	if (read >= 0 && trace_parser_loaded((&parser))) {
-- 
2.10.2

  parent reply	other threads:[~2017-02-03 13:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 13:40 [for-next][PATCH 0/8] tracing: Clean up hash logic for set_graph_function Steven Rostedt
2017-02-03 13:40 ` [for-next][PATCH 1/8] tracing: Add ftrace_hash_key() helper function Steven Rostedt
2017-02-03 13:40 ` [for-next][PATCH 2/8] ftrace: Create a slight optimization on searching the ftrace_hash Steven Rostedt
2017-02-03 14:26   ` Namhyung Kim
2017-02-03 14:57     ` Steven Rostedt
2017-02-03 13:40 ` [for-next][PATCH 3/8] ftrace: Replace (void *)1 with a meaningful macro name FTRACE_GRAPH_EMPTY Steven Rostedt
2017-02-03 13:40 ` [for-next][PATCH 4/8] ftrace: Reset fgd->hash in ftrace_graph_write() Steven Rostedt
2017-02-03 14:49   ` Namhyung Kim
2017-02-03 14:57     ` Steven Rostedt
2017-02-03 13:40 ` Steven Rostedt [this message]
2017-02-03 13:40 ` [for-next][PATCH 6/8] tracing: Reset parser->buffer to allow multiple "puts" Steven Rostedt
2017-02-03 13:40 ` [for-next][PATCH 7/8] ftrace: Do not hold references of ftrace_graph_{notrace_}hash out of graph_lock Steven Rostedt
2017-02-03 13:40 ` [for-next][PATCH 8/8] ftrace: Have set_graph_function handle multiple functions in one write Steven Rostedt
2017-02-03 15:14 ` [for-next][PATCH 0/8] tracing: Clean up hash logic for set_graph_function Namhyung Kim

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=20170203134137.445198321@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@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