From: tip-bot for Li Zefan <lizf@cn.fujitsu.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
lizf@cn.fujitsu.com, jolsa@redhat.com, fweisbec@gmail.com,
rostedt@goodmis.org, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:tracing/urgent] tracing: Check the return value of trace_get_user()
Date: Tue, 22 Sep 2009 08:39:50 GMT [thread overview]
Message-ID: <tip-4ba7978e98a3ff92cebfb0f31a02c309e3ffa1fe@git.kernel.org> (raw)
In-Reply-To: <4AB86614.7020803@cn.fujitsu.com>
Commit-ID: 4ba7978e98a3ff92cebfb0f31a02c309e3ffa1fe
Gitweb: http://git.kernel.org/tip/4ba7978e98a3ff92cebfb0f31a02c309e3ffa1fe
Author: Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Tue, 22 Sep 2009 13:52:20 +0800
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 22 Sep 2009 10:28:55 +0200
tracing: Check the return value of trace_get_user()
Return immediately if trace_get_user() returned failure.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <4AB86614.7020803@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/trace/ftrace.c | 9 ++++-----
kernel/trace/trace_events.c | 7 +++----
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c71e91b..a8fe478 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2202,7 +2202,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
struct trace_parser *parser;
ssize_t ret, read;
- if (!cnt || cnt < 0)
+ if (!cnt)
return 0;
mutex_lock(&ftrace_regex_lock);
@@ -2216,7 +2216,7 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
parser = &iter->parser;
read = trace_get_user(parser, ubuf, cnt, ppos);
- if (trace_parser_loaded(parser) &&
+ if (read >= 0 && trace_parser_loaded(parser) &&
!trace_parser_cont(parser)) {
ret = ftrace_process_regex(parser->buffer,
parser->idx, enable);
@@ -2552,8 +2552,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
struct trace_parser parser;
- size_t read = 0;
- ssize_t ret;
+ ssize_t read, ret;
if (!cnt || cnt < 0)
return 0;
@@ -2572,7 +2571,7 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
read = trace_get_user(&parser, ubuf, cnt, ppos);
- if (trace_parser_loaded((&parser))) {
+ if (read >= 0 && trace_parser_loaded((&parser))) {
parser.buffer[parser.idx] = 0;
/* we allow only one expression at a time */
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 6f03c8a..d128f65 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -232,10 +232,9 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
size_t cnt, loff_t *ppos)
{
struct trace_parser parser;
- size_t read = 0;
- ssize_t ret;
+ ssize_t read, ret;
- if (!cnt || cnt < 0)
+ if (!cnt)
return 0;
ret = tracing_update_buffers();
@@ -247,7 +246,7 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
read = trace_get_user(&parser, ubuf, cnt, ppos);
- if (trace_parser_loaded((&parser))) {
+ if (read >= 0 && trace_parser_loaded((&parser))) {
int set = 1;
if (*parser.buffer == '!')
next prev parent reply other threads:[~2009-09-22 8:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-22 5:51 [PATCH 1/4] tracing: fix off-by-one in trace_get_user() Li Zefan
2009-09-22 5:52 ` [PATCH 2/4] tracing: check the return value of trace_get_user() Li Zefan
2009-09-22 8:39 ` tip-bot for Li Zefan [this message]
2009-09-22 5:52 ` [PATCH 3/4] tracing: fix failure path in ftrace_graph_write() Li Zefan
2009-09-22 8:40 ` [tip:tracing/urgent] tracing: Fix " tip-bot for Li Zefan
2009-09-22 5:54 ` [PATCH 4/4] tracing: fix failure path in ftrace_regex_open() Li Zefan
2009-09-22 8:40 ` [tip:tracing/urgent] tracing: Fix " tip-bot for Li Zefan
2009-09-22 8:39 ` [tip:tracing/urgent] tracing: Fix off-by-one in trace_get_user() tip-bot for Li Zefan
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-4ba7978e98a3ff92cebfb0f31a02c309e3ffa1fe@git.kernel.org \
--to=lizf@cn.fujitsu.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.