Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbcDZQhS (ORCPT ); Tue, 26 Apr 2016 12:37:18 -0400 Received: from smtprelay0106.hostedemail.com ([216.40.44.106]:52803 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751966AbcDZQhQ (ORCPT ); Tue, 26 Apr 2016 12:37:16 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3150:3353:3622:3865:3866:3867:3868:3870:3871:4321:4362:5007:6119:6261:7576:7875:9545:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12438:12517:12519:12555:12740:13069:13255:13311:13357:13439:14093:14097:14180:14181:14659:14721:21060:21080:30029:30051:30054:30064:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: shape75_5c47847c7a637 X-Filterd-Recvd-Size: 2950 Date: Tue, 26 Apr 2016 12:37:11 -0400 From: Steven Rostedt To: Wang Xiaoqiang Cc: Chunyu Hu , Peter Zijlstra , Jiaxing Wang , Chen Gang , "Rafael J. Wysocki" , Joe Perches , linux-kernel@vger.kernel.org Subject: Re: [PATCH] tracing: Don't use the address of the buffer array name in copy_from_user Message-ID: <20160426123711.2aa4ce34@gandalf.local.home> In-Reply-To: <20160418152329.18b72bea@debian> References: <20160418152329.18b72bea@debian> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1856 Lines: 68 On Mon, 18 Apr 2016 15:23:29 +0800 Wang Xiaoqiang wrote: > Hi, all, > > From 7dbacb179a4d5f9ac9d7e1b3733664b3b0fe23ae Mon Sep 17 00:00:00 2001 > From: Wang Xiaoqiang > 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 > --- > 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;