Received: by 10.192.165.148 with SMTP id m20csp3963380imm; Tue, 8 May 2018 00:02:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrngQgHMkZwUQMfxz2XnnHdX0cJlRzojX/mLVSt8yi4hEB7+VPbq05oQ9m8jR3tyPHcCUpV X-Received: by 2002:a63:b908:: with SMTP id z8-v6mr31772886pge.436.1525762975850; Tue, 08 May 2018 00:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525762975; cv=none; d=google.com; s=arc-20160816; b=wJM2442/ZT5VaBlZKfLoXty41SzyjXCEkT5ZLneL3TVPsmu9CIgSvYdb/OZdd1RYeV RBnD2DoNEQI6MyD1MCZPFOSBDvjNFe2key8BdkKXsqDZ3xgHNYYKkPmo7ste9OP2wxVN LO0FSJkC9G0DcWqNBb/qzFWK2D5aNFwxn2AlaJQ8RJjcFIdDwL3Fw5Ck7TeeEEVIJlWI W5wb58kdekUOzzsv2q+FIwGoTOW1QJ9N3NAmOWNBjKCgz99NEAeHH5DD+i/paUwJMYNY IjURyMF6KtQ4rvfoEjwMYj5r/n1Wq9k0H+HqscS8uZL7bgASX9tSCq7Rb70hWgOoBKiQ 1d9g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=o3x5KbDinEUct1g+fRKuaICEDpX1N0kJ6HFC9likINE=; b=K/HpfEAWzCXoynWTtQl5+VbZKIex7z1KY5+c85Mul8SGqejf8UzmZyZ8h/Dqh5HeKI tVGRGQk28F6udoxLuU6THhiku+f0aD/L8oBPeXvtZTjdbjDj0aqvKhgaJf3vl4CXO9Sv pTRXObq9GIW52E/QH2gnQgVrRaFcSL9h7cB5Y2j4QMVuIaOwaWZzsLpdBoiJK3JT3jBV shDccK3mzKzfpTaDUY0pOQ/BK3Th6VqhV74qf0H0DH03iyILYjudlUYcosbLRH9fbA6N xOZxtTysj3efJJYQYwaPfiS/X1MUdr+1YhkebpTpNu8eGczO0HtdwJgQpsEXoyXgIo4e LolQ== 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 r18-v6si8851656pge.7.2018.05.08.00.02.41; Tue, 08 May 2018 00:02:55 -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 S1754470AbeEHHCK (ORCPT + 99 others); Tue, 8 May 2018 03:02:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:47318 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754417AbeEHHCI (ORCPT ); Tue, 8 May 2018 03:02:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1DDAFADC4; Tue, 8 May 2018 07:02:07 +0000 (UTC) Subject: Re: [PATCH] xen: xenbus: Fix a possible data race in xs_request_enter To: Jia-Ju Bai , boris.ostrovsky@oracle.com, simon@invisiblethingslab.com, joao.m.martins@oracle.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org References: <20180508033429.12749-1-baijiaju1990@gmail.com> From: Juergen Gross Message-ID: Date: Tue, 8 May 2018 09:02:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180508033429.12749-1-baijiaju1990@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/05/18 05:34, Jia-Ju Bai wrote: > The read operation to "req->type" is protected by > the lock on line 128, but the write operation to > this data on line 118 is not protected by the lock. > Thus, there may exist a data race for "req->type". > > To fix this data race, the write operation to "req->type" > should be also protected by the lock. No, xs_request_enter() is never called for a request already visible to another thread or processor. So no race exists. Juergen > > Signed-off-by: Jia-Ju Bai > --- > drivers/xen/xenbus/xenbus_xs.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c > index 49a3874ae6bb..274cdfee08b1 100644 > --- a/drivers/xen/xenbus/xenbus_xs.c > +++ b/drivers/xen/xenbus/xenbus_xs.c > @@ -115,10 +115,10 @@ static uint32_t xs_request_enter(struct xb_req_data *req) > { > uint32_t rq_id; > > - req->type = req->msg.type; > - > spin_lock(&xs_state_lock); > > + req->type = req->msg.type; > + > while (!xs_state_users && xs_suspend_active) { > spin_unlock(&xs_state_lock); > wait_event(xs_state_enter_wq, xs_suspend_active == 0); >