tracing: Don't use the address of the buffer array name in copy_from_user
PATCH 1/1 tracing: Don't use the address of the buffer array name in copy_from_user
Hi, all,
Quoted 1 line
From
7dbacb179a4d5f9ac9d7e1b3733664b3b0fe23aeMon Sep 17 00:00:00 2001
From: Wang Xiaoqiang <[email protected]>
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".
--- kernel/trace/trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/trace.c +3 -3
@@ -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 ;
Signature · 1 line
2.1.4
Steven Rostedt
maintainerQuoted 9 lines · On Mon, 18 Apr 2016 15:23:29 +0800 Wang Xiaoqiang <[email protected]> wrote:
Hi, all,
From
7dbacb179a4d5f9ac9d7e1b3733664b3b0fe23aeMon Sep 17 00:00:00 2001
From: Wang Xiaoqiang <[email protected]>
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_userFix the problem as follows:
What problem is being fixed?
Quoted 9 lines
... 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
Quoted 37 lines
Signed-off-by Wang Xiaoqiang <[email protected]>--- kernel/trace/trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)kernel/trace/trace.c +3
-3@@ -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 ;