All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Chunyu Hu <chuhu@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Jiaxing Wang <hello.wjx@gmail.com>,
	Chen Gang <gang.chen.5i5j@gmail.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Joe Perches <joe@perches.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] tracing: Don't use the address of the buffer array name in copy_from_user
Date: Mon, 18 Apr 2016 15:23:29 +0800	[thread overview]
Message-ID: <20160418152329.18b72bea@debian> (raw)

Hi, all,

>From 7dbacb179a4d5f9ac9d7e1b3733664b3b0fe23ae Mon Sep 17 00:00:00 2001
From: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
Date: Mon, 18 Apr 2016 14:58:15 +0800
Subject: [PATCH] tracing: Don't use the address of the buffer array name in
 copy_from_user

Fix the problem as follows:

    ...
    char buf[64];
    ...
    if (copy_from_user(&buf, ubuf, cnt))
    ...

Even though the value of "&buf" equals "buf", but there is no need
to get the address of the "buf" again. Use "buf" replace "&buf".

Signed-off-by: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
---
 kernel/trace/trace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a2f0b9f..422ab57 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3658,7 +3658,7 @@ tracing_trace_options_write(struct file *filp, const char __user *ubuf,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (copy_from_user(buf, ubuf, cnt))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -4474,7 +4474,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
 	if (cnt > MAX_TRACER_SIZE)
 		cnt = MAX_TRACER_SIZE;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (copy_from_user(buf, ubuf, cnt))
 		return -EFAULT;
 
 	buf[cnt] = 0;
@@ -5264,7 +5264,7 @@ static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (copy_from_user(buf, ubuf, cnt))
 		return -EFAULT;
 
 	buf[cnt] = 0;
-- 
2.1.4

             reply	other threads:[~2016-04-18  8:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18  7:23 Wang Xiaoqiang [this message]
2016-04-26 16:37 ` [PATCH] tracing: Don't use the address of the buffer array name in copy_from_user Steven Rostedt

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=20160418152329.18b72bea@debian \
    --to=wangxq10@lzu.edu.cn \
    --cc=chuhu@redhat.com \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=hello.wjx@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rostedt@goodmis.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 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.