Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp405802imm; Wed, 13 Jun 2018 02:19:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIE09P6G7BqLdySvgIcIdZCYeDvBNGxGp4wqM3FMfsnbfmDB6URNrbauakzhyBBS6aGsBla X-Received: by 2002:a17:902:600a:: with SMTP id r10-v6mr4397170plj.70.1528881546363; Wed, 13 Jun 2018 02:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528881546; cv=none; d=google.com; s=arc-20160816; b=Ia0qP8vtx7sxTfguhODPBzmrXy3QtPhBbmmCtazWt21XgJ3lDety5xlo5pG7UUeKAA Gg7S40ZXTduvFoNwW66/puOaLfwxTvcIHCVBVA9hgjss/xo0H8ePdGzuyTMhQ/a+T3Ij eFPHSmpKvjQP9s7qdN6x516L0qOyvVdhZMEaSzTd/vNrQ3PfcKZyXexjYw5vhsakY5ES htOZRxWVNEFtBKQZvnq02p0U6L5jEDaYoHlmkmN8tRzuUoNX7gaF1QzQJhDilg5maqTr TSoV91x891tLyO7uaPzBJMLlkFEhWrkMWOnigxYs4Nt/o5Y0zgPN4IpSNMto45kreEjk WgGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=StjdrJxoIV5mVjXNd7KrPtGp01o53nnHPN28U4GltxY=; b=vfDrIp93BDlmNECsZYPc89wuNN6A2D/kr6e9nlHZ8FY6T32K6CARS0T8Oi82Ep9hl2 3uVJWfDLBITu130MMiRDWUhmxrDohqzK8H6wCigRF0kNHeR9q6l8aCQxqv6qoyITSJWK Zg2oMl8+CadnfpTqZ6o/Tkva8CSLtvyP18dVhbIy0R2iFf0EG7D7FIjAwvqg9uKW/z+D /EUGI/H3LzNicThiTFAbU07npW9P6Gz8AKeEaBoVb8lJ/Xfmw3W9U636xNWDjOFGW/7l fy5ZO3gt7FFMActb/D9+dzxr+6Y4Ey8CskNYZLaHEtuv6SeQg62iaCVlOy5U81xjFzgB eeCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=sOi6VEEe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c3-v6si2337697pld.87.2018.06.13.02.18.52; Wed, 13 Jun 2018 02:19:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=sOi6VEEe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935013AbeFMJRK (ORCPT + 99 others); Wed, 13 Jun 2018 05:17:10 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45052 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934073AbeFMJRJ (ORCPT ); Wed, 13 Jun 2018 05:17:09 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5D9GHn7149869; Wed, 13 Jun 2018 09:17:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=StjdrJxoIV5mVjXNd7KrPtGp01o53nnHPN28U4GltxY=; b=sOi6VEEebOQDk7do2gIrFcOgpuC+VWjTQQyrRxtboFKtDbDOcVnR6Pnw8kDzkUOBz/m7 cFXf614RliSPIqbb1PGKKw/V0/3b0kW2A7Ay+NZ0p44fEG59gO0hnIBK3dmwbvmD3bpn d+wHWy3CbzUGwi9FFOHrWToKrm9KdWs7VVgbLjgAz08I+wPMAxYdbsicHwKPGhAie7jt IwNU5eAA3RQTtg3qGh3ItXx7QW5ZGWFZveeDKpGYRkXAk3NhdBdxVEuIM2jXGFzht2U6 /eRrQiYHvPxgG3rqglfIqRCEDOgxtbGjWubbuKAmBAbvRWvzkWwVwtWxobsTMlWEQDvW BA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2jjp6bsjvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Jun 2018 09:17:01 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5D9Gxoi023249 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Jun 2018 09:17:00 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5D9GxZA031000; Wed, 13 Jun 2018 09:16:59 GMT Received: from mwanda (/197.157.34.169) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Jun 2018 02:16:58 -0700 Date: Wed, 13 Jun 2018 12:16:49 +0300 From: Dan Carpenter To: Hugo Lefeuvre Cc: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Marcus Wolf , linux-kernel@vger.kernel.org, kernelnewbies@kernelnewbies.org Subject: Re: [PATCH v2] staging: pi433: fix race condition in pi433_ioctl Message-ID: <20180613091649.r3bck3wjma6tmjet@mwanda> References: <20180613014741.GC2265@hle-laptop.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180613014741.GC2265@hle-laptop.local> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8922 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806130103 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 12, 2018 at 09:47:41PM -0400, Hugo Lefeuvre wrote: > drivers/staging/pi433/pi433_if.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c > index b061f77dda41..3ec1ed01d04b 100644 > --- a/drivers/staging/pi433/pi433_if.c > +++ b/drivers/staging/pi433/pi433_if.c > @@ -880,6 +880,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > int retval = 0; > struct pi433_instance *instance; > struct pi433_device *device; > + struct pi433_tx_cfg tx_cfg_buffer; > void __user *argp = (void __user *)arg; > > /* Check type and command number */ > @@ -902,9 +903,15 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) > return -EFAULT; > break; > case PI433_IOC_WR_TX_CFG: > - if (copy_from_user(&instance->tx_cfg, argp, > - sizeof(struct pi433_tx_cfg))) > + /* do not modify tx config while it is being copied to fifo */ There is no need for this comment, since it's obvious. Also if you use simpler names then the copy fits on one line: if (copy_from_user(&tx_cfg, argp, sizeof(tx_cfg)) { > + mutex_lock(&device->tx_fifo_lock); > + if (copy_from_user(&tx_cfg_buffer, argp, > + sizeof(struct pi433_tx_cfg))) { Sorry for the duplicate review, but it got sent to both my inboxes... :P regards, dan carpenter