Received: by 10.192.165.148 with SMTP id m20csp3815733imm; Mon, 7 May 2018 20:35:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8hwwIc9y20yJwQUFCb+CavO/swKEoR5SiqylLfNmw6cbGl5Tk37THpDXf6CBwJXfVKqQC X-Received: by 2002:a17:902:9349:: with SMTP id g9-v6mr37891133plp.375.1525750504144; Mon, 07 May 2018 20:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525750504; cv=none; d=google.com; s=arc-20160816; b=iNZKCCsVJ23Hs1pciodVQJSFpEVSBuwU6UeUPLMbZ15mPTOU01CSssIK+IRFb/Ka/Q Cr2nUI2jhZvv7B1JTGLDBZXQCeZJ/gttmhs/QhNISec8ZiFJRoVs76kPkpLgfd26GjNC Z00vOxtehewPZ/Udv8iKXffZ4DjQL5zQtHEe+s4xcdSONLoBoQO8/PjpTkm8DqCTazt7 5UiSlF3ViQlHRg/6Hw4Qs4ZdPUAPfBH3UJ83yoQQ1MOJElYv0bOKvCw7Xtt3QV81imyr m1l9WGmJGCOQag+7vJFmTwJn5OWZtpFwAutEtma5HiauqfL+Wv9YTASYAT4RJoCeRH2T /5Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=cTLKTtT3aS1fm0H1Vfd/5/FFtTZ/1kHB8rn5YFttKw0=; b=bWC05aSvGHOg/Dw0b5xtPcTuWCO4zAMpRueljbnQ0SZvH7ObM+rxlPXlDRzcsUBgl3 VEIl1sNHdO3+CDLT98fLirWaeJeOLUaP8Vgnf+v2PiOE8IpxqIxDyUWAyJBH1zf/qmOM aS1QjWttgF3LSLNH3gwJ67OcqdA5r1ouQkU8w7z1K8xi+E8YPeJjN9ZVHy6IS01c4X8X Ntor8o0ZPbLciEciEvjw5GCfxEYL5jEXdh9RGl+npbQm1NIhP4FB90J4yjbl64P6Oefm E6zcH/2GzFlK/qpwXH7jI6cU4iss/l+MhFl4VcoZXWd1H3WBa7dpXINqeDIMlQxF+rpl WVog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tJD5Iq1F; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t85-v6si18473444pgb.42.2018.05.07.20.34.50; Mon, 07 May 2018 20:35:04 -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=@gmail.com header.s=20161025 header.b=tJD5Iq1F; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754048AbeEHDei (ORCPT + 99 others); Mon, 7 May 2018 23:34:38 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:42409 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753846AbeEHDeh (ORCPT ); Mon, 7 May 2018 23:34:37 -0400 Received: by mail-pl0-f68.google.com with SMTP id u6-v6so1362255pls.9 for ; Mon, 07 May 2018 20:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=cTLKTtT3aS1fm0H1Vfd/5/FFtTZ/1kHB8rn5YFttKw0=; b=tJD5Iq1F3+mv6WCwwK2K1wmK6P+upX18rnQVZw5APqh0XvNucECcOe4DMSI4qozcJg R1GqhgqP+l5fiImiJeNufVAgldp8KAiZbf29CIfPq+5hWCkgLOirzAyMlNMHEp935fqy zBZWWWVrqr2QI8uY19Vw+uLBYKYnItrlRsgLRU07jy+Y/lvHhLattSP+M6HJxIqU/AOT 2YtlEAxpEJU6OIzCODByxK6PwYmq4JKfJSV3Jv5/Ndyl7Z+LaqJz0EPKmo4xNlkP/Uej Gk84gZG/WxEO2X4Lbrm623OQM8bKeJkaOYz/8OZR7ov3JMpmzPV9BAUHzLgwrPyXro7b QPIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cTLKTtT3aS1fm0H1Vfd/5/FFtTZ/1kHB8rn5YFttKw0=; b=UlnsKE+fg3lovnz+pvR+1Oy2RsYZeQ+uMb/wpj/ngEGahLt10TvA3zYaydifAowvHz bHZLwZcuo2S1cDgWAdKXPrdTDi7JHTMr26L/hMBcP0WLqRWbUxLynS1vFrm5CZzk//0W WvZ5qjvAmDDGRpE+efDFUb3mV52mJTJj+MdVLdhWYK15q9AXwd3PoRBQD7v0lp7qudmA NbYjqaqx3HhFL5d3lvMo5IH/GwRobU59KQs9jMNaTp6PbxQf73AU1b09UNS4iceXahxQ n5WCzZ5uCUjRwplEZcex1qxD00/XeagWpK89Y1jPRqY0DH7soyHwO+QDziE6hsQN0IdV W+TA== X-Gm-Message-State: ALQs6tDsV8EgCYwT/O6Jdx7B9xruC1WjEWlcur26q0kYwBA0Cj+q1UGw J/sXwk+IVSsNIENUnORVVJ4= X-Received: by 2002:a17:902:a717:: with SMTP id w23-v6mr6788043plq.130.1525750477160; Mon, 07 May 2018 20:34:37 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:18bf:4b0b:7f52:49b]) by smtp.gmail.com with ESMTPSA id t68sm5567129pfe.17.2018.05.07.20.34.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 20:34:36 -0700 (PDT) From: Jia-Ju Bai To: boris.ostrovsky@oracle.com, jgross@suse.com, simon@invisiblethingslab.com, joao.m.martins@oracle.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] xen: xenbus: Fix a possible data race in xs_request_enter Date: Tue, 8 May 2018 11:34:29 +0800 Message-Id: <20180508033429.12749-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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); -- 2.17.0