Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2150199imm; Sat, 9 Jun 2018 08:49:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI6twmYMt0fn7DS3PRW2BmFsRKpYcYPjiRQW6pGGEKGJoYsVLii9HT4fiLDyGS2ddEdyZul X-Received: by 2002:a17:902:b611:: with SMTP id b17-v6mr11241557pls.284.1528559378991; Sat, 09 Jun 2018 08:49:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528559378; cv=none; d=google.com; s=arc-20160816; b=ePrnwA6fi4LNiTIqmMs4yS3mIWgBzAn97cFwJLE5ZSzR0hFBhEA96c5YYZkdXx1XXo 2996KL5B4XbkdtgJJ9zrPHB+VD8oBDyOe1ACuMAdLUAeRXjbWm893Emn8DshQSgVOZbK 6Bewh8+1zU52xAl/xhEgPVlIJx1r8JsfB4oD1LPn/+o7oFUWT9EV0006XdwRvC9tBBg/ Y8w1tKB02mXmRlFPGwhTBmM1vqrQME/LRYpPF5BK9NKUv8CRYcMr0jgNEmGzJlBK6xgm wJajjDWCrYTHohx/YSg+z5XchmvEbBBtZk00ozvOCr3cOv/jOQFZL2pas6x1jQ9JORgX FctQ== 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:arc-authentication-results; bh=kROdw9hzfposzpHMzDMd+uzbW3x2/S5ioZcheUv4VA8=; b=ESPfAQ34ENF0+o6Pcmg7GWiyuJ8N/4T1WNMpIEKYmnsGqpn1J2x9q4yau8gDCkimYF 7xNEBtaiJ9aCa38h4FHv/yNNAmE6HwL281N1LquGIeBZvB8+e3d9dBXWph7lsuxHaErB zlWfDEGAdGA0/mL/N3KOv1iY+j2S7D7U45RQYAOWEq9QXbiuJ+6tY9CX8uJKlAm9FxcW 9eWmN/gCCm5H0cWE47L3o5FMdwixfCAZPECQcJSkoJov4j5Xr+G/wDDQzcrva45+Sohy w0EUUpn37155bEo91FT/FR5yyBCa/rSfjVq1MFWQ/oLwrodDwhvQRmLYOnEAr8KyjZGF GjAw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f91-v6si59879239plb.510.2018.06.09.08.49.24; Sat, 09 Jun 2018 08:49:38 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932612AbeFIPsu (ORCPT + 99 others); Sat, 9 Jun 2018 11:48:50 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:46389 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932530AbeFIPss (ORCPT ); Sat, 9 Jun 2018 11:48:48 -0400 X-Originating-IP: 96.22.60.141 Received: from localhost (modemcable141.60-22-96.mc.videotron.ca [96.22.60.141]) (Authenticated sender: hle@owl.eu.com) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id ADC1C60003; Sat, 9 Jun 2018 15:48:45 +0000 (UTC) Date: Sat, 9 Jun 2018 11:48:42 -0400 From: Hugo Lefeuvre To: Valentin Vidic Cc: devel@driverdev.osuosl.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernelnewbies@kernelnewbies.org Subject: Re: [PATCH v2] staging: pi433: add mutex fixing concurrency issues. Message-ID: <20180609154842.GB1826@hle-laptop.local> References: <20180602175649.GA2816@hle-laptop.local> <20180607124216.GA2329@hle-laptop.local> <20180609081244.GP14048@gavran.carpriv.carnet.hr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180609081244.GP14048@gavran.carpriv.carnet.hr> User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Level: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > After discussing this issue on the kernel newbies mailing list[0] we > > came to the conclusion that it is very unlikely that pi433_release and > > pi433_ioctl would ever run concurrently in this case. This is also > > true for read/write. Unless one can find a situation where this might > > happen, I think we should not add this potentially unnecessary lock. > > Yes, so we should than drop the TODO comment on this issue? Well, after taking a closer look it appears that I misunderstood the TODO. What this TODO means is that we might run into a whole world of issues if the device is _removed_ while we're running ioctl or I guess pretty much any function that accesses the struct pi433_device. So the issue doesn't come from pi433_release and pi433_ioctl running concurrently, but rather pi433_ioctl and pi433_remove. Whether this situation is likely to happen or not is another question which I am currently taking a look at. Also, during my work on this driver I found what I'd consider as another issue: In pi433_ioctl we execute case PI433_IOC_WR_TX_CFG: if (copy_from_user(&instance->tx_cfg, argp, sizeof(struct pi433_tx_cfg))) return -EFAULT; break; without any synchronization. What if two ioctl syscalls are called with command PI433_IOC_WR_TX_CFG ? instance->tx_cfg might get corrupt unless copy_from_user provides some kind of synchronization, right ? I have prepared a patch but couldn't test it because I don't have test devices. -- Hugo Lefeuvre (hle) | www.owl.eu.com 4096/ 9C4F C8BF A4B0 8FC5 48EB 56B8 1962 765B B9A8 BACA