Received: by 10.192.165.148 with SMTP id m20csp4033730imm; Tue, 8 May 2018 01:35:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZonTWMXcoP/RjtZKSMqJvcisCYCLVldP67ogfiFlj077TrkneDzmI301jr5tIBMTPjWJrdG X-Received: by 10.98.108.135 with SMTP id h129mr20238771pfc.179.1525768524544; Tue, 08 May 2018 01:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525768524; cv=none; d=google.com; s=arc-20160816; b=hv9IjJfd7IS4XbfR3RmpvbUOK/WFGoRgg4Zi9af6GuF9HqXC8Zuf/Ut06h+92OUyo5 IUSy0OAtAPWvOBir7E4uDIltoiUiQGa6AUwQ2pHF2emLaZpKCEecfEY3qb2MlNpnQfci GYzr8M0dm3mBjmEUJuSrtJ+2ZB+3tH+23BeucuXwEq20rqchCOGP+Ro62cn3yqqfVvtA 0JlS3raAiVR4mWJS81n+fASoKXsSfzL1lh6s8XJRNVVJPoWMmqIhWy5DSIiegUyA3QTg EMGmoUnPcZQHHKhxwzgAcPPAWZ4fPjYn0CIt4fqcajbgY8M/tUP4YjJh7sVKH9NiCoBY xWzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=r57l+jRsG9JJtYtduHQE8eGhrJcp9/Be/qZu/aMxkVs=; b=UUnYAGG++CUYX3C82Y7rgheGU2EaOokPlB7NMcBQdrcwd+7Dme1FcT0S1E6OZ5InQE EUCZ9xbo1X3EJLkXKmXRBmV2fNdlRLSNG0PcJd383WCZIn+CB8zRPyIpn0YsxQf+nRsG h7tE3f897kFXrOejWf+rprw6CG/ayi5KMi6MvHKVI90Vfn84k6KE+rZ0JTNa/m/XiOA4 YhTp2fhg63zk8hrJCQIk7YofiR3ndBMhjWdU0mzIgp0x5psupNA5Q4sBTAmJyiYkIeHJ LkL/gacf6+G1mZcplgEbNyWrEOKdaaBfOCU2nWNnKCaqcSvjXJIGi5jYsW2UwJBupP6w jWUg== 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 g9-v6si18808394pgv.218.2018.05.08.01.35.10; Tue, 08 May 2018 01:35:24 -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 S933180AbeEHIec (ORCPT + 99 others); Tue, 8 May 2018 04:34:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:45194 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932646AbeEHIea (ORCPT ); Tue, 8 May 2018 04:34:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B47C7AB5D; Tue, 8 May 2018 08:34:28 +0000 (UTC) Message-ID: <1525768070.24345.8.camel@suse.com> Subject: Re: [usb-storage] [PATCH] usb: storage: Fix a possible data race in uas_queuecommand_lck From: Oliver Neukum To: Jia-Ju Bai , stern@rowland.harvard.edu, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-scsi@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org Date: Tue, 08 May 2018 10:27:50 +0200 In-Reply-To: <20180508074743.13622-1-baijiaju1990@gmail.com> References: <20180508074743.13622-1-baijiaju1990@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Dienstag, den 08.05.2018, 15:47 +0800 schrieb Jia-Ju Bai: > The write operations to "cmnd->result" and "cmnd->scsi_done" > are protected by the lock on line 642-643, but the write operations > to these data on line 634-635 are not protected by the lock. > Thus, there may exist a data race for "cmnd->result" > and "cmnd->scsi_done". No, the write operations need no lock. The low level driver at this point owns the command. We cannot race with abort() for a command within queuecommand(). We take the lock where we take it to protect dev->resetting. I don't see why the scope of the lock would need to be enlarged. Regards Oliver > To fix this data race, the write operations on line 634-635 > should be also protected by the lock. > > Signed-off-by: Jia-Ju Bai Nacked-by: Oliver Neukum