mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Wang Xiaoqiang <wangxq10@lzu.edu.cn>
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: Re: [PATCH] tracing: Don't use the address of the buffer array name in copy_from_user
Date: Tue, 26 Apr 2016 12:37:11 -0400	[thread overview]
Message-ID: <20160426123711.2aa4ce34@gandalf.local.home> (raw)
In-Reply-To: <20160418152329.18b72bea@debian>

On Mon, 18 Apr 2016 15:23:29 +0800
Wang Xiaoqiang <wangxq10@lzu.edu.cn> wrote:

> 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:

What problem is being fixed?

> 
>     ...
>     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".

I'll take this, but more as a cleanup and not a "fix".

Thanks,

-- Steve

> 
> 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;

      reply	other threads:[~2016-04-26 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18  7:23 Wang Xiaoqiang
2016-04-26 16:37 ` Steven Rostedt [this message]

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=20160426123711.2aa4ce34@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --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=wangxq10@lzu.edu.cn \
    /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

all inboxes | Powered by JetHome®