Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp792280ybe; Fri, 13 Sep 2019 06:28:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxemZzai8hPUGoV0HK4fIpzfS/Kfw9DEONrt1XZu/cH2w9MTZl3S2p2m9Nsx2Rsv8jAe/ZR X-Received: by 2002:a05:6402:b2d:: with SMTP id bo13mr46854903edb.170.1568381293577; Fri, 13 Sep 2019 06:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381293; cv=none; d=google.com; s=arc-20160816; b=BhsAhxeZA5diBFClPrRc96Dv6VV/owXjvgwfCjBxF8N/YB8XUFrADaiciRfiTJqsqS +EG0lFV4eUkdNuO589e8a4g7XFRVHLGY7JKJomRfsZdgGq4a1WDRPtbvloXvNRVzfGSH 4vSfRLLrjyiYYKWMkYnyVvLI16Fq6FSptv50rBDo3tcaZ/+7q5yVxN73fwzU7AsBKMSF bzWNSVPHdgZfOGrt3BFyqK0suBmtDQfebywGkVV+PrBn2TeNxuA0AKA94PBwXpBbOH7t IYoyuw7DqcwWGxDtoEEJ9NmVgOovFgvLWkwyjkBiknEZdQi/E8DHy+47VrCDgAfdJbcg /org== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EUlYzgj9T30t7TzLXdTzdfdWRtxJYAFVo9TlNPUkvxY=; b=Y+VyGhGHMSLIMNaZ1a/i60+cjkRT6Qu54scGqPQELrjtxyo+pzWEqLgKhEVf1fyOy+ en05ItC1fufPcjJKnDXoQeC7fZG8c0Zr20P4NFAJJRZBip1VWTKfTwAvkE5bY/5jSBxp PxQrBFITK5y79f7PnW7tJL5Nq2z4yfuvWQ60kd24K9zZf+2Yian6mz0shxHRlkSHuMks lSxA9ig3lvTgbsss64qEOFKw3qxWrpn0/ahDCd1Dwh2duqffAtIeTVS3BglqYNjH2Zg8 pZwIkXx/e4k1xd13dl79kuPn1qHepFq0tlV9rxk97F6QfB3sTlQ5I+GhC119yWv9SD31 brXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Pt4JnI8y; 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 d17si13834373edr.294.2019.09.13.06.27.50; Fri, 13 Sep 2019 06:28:13 -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=@kernel.org header.s=default header.b=Pt4JnI8y; 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 S2390985AbfIMNWM (ORCPT + 99 others); Fri, 13 Sep 2019 09:22:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:52418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390973AbfIMNWL (ORCPT ); Fri, 13 Sep 2019 09:22:11 -0400 Received: from localhost (unknown [104.132.45.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73AEA214AE; Fri, 13 Sep 2019 13:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568380930; bh=/nvSdDdkuOkxtV8ySXQRCik+0vs/UJWaIb4atO2eONE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pt4JnI8ySVxr4+V24ZrvjPAm1pXi5STlm4uP6I9xXLodhpZyD5rxzwfgwpTef91rU oyMhvhor/79XCUn4SJQbOqzKjOzkPXsOoeWHN01b9SmKWGUkRFZ1HIk0RGx7AWUeb6 J0kIP89ukcBaEOWRGb9dtSiEvjph9i5fx972dURI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Halil Pasic , Marc Hartmayer , Cornelia Huck , Heiko Carstens , Sasha Levin Subject: [PATCH 5.2 29/37] virtio/s390: fix race on airq_areas[] Date: Fri, 13 Sep 2019 14:07:34 +0100 Message-Id: <20190913130521.250696506@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913130510.727515099@linuxfoundation.org> References: <20190913130510.727515099@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 4f419eb14272e0698e8c55bb5f3f266cc2a21c81 ] The access to airq_areas was racy ever since the adapter interrupts got introduced to virtio-ccw, but since commit 39c7dcb15892 ("virtio/s390: make airq summary indicators DMA") this became an issue in practice as well. Namely before that commit the airq_info that got overwritten was still functional. After that commit however the two infos share a summary_indicator, which aggravates the situation. Which means auto-online mechanism occasionally hangs the boot with virtio_blk. Signed-off-by: Halil Pasic Reported-by: Marc Hartmayer Reviewed-by: Cornelia Huck Cc: stable@vger.kernel.org Fixes: 96b14536d935 ("virtio-ccw: virtio-ccw adapter interrupt support.") Signed-off-by: Heiko Carstens Signed-off-by: Sasha Levin --- drivers/s390/virtio/virtio_ccw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c index 6a30768813219..8d47ad61bac3d 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c @@ -132,6 +132,7 @@ struct airq_info { struct airq_iv *aiv; }; static struct airq_info *airq_areas[MAX_AIRQ_AREAS]; +static DEFINE_MUTEX(airq_areas_lock); #define CCW_CMD_SET_VQ 0x13 #define CCW_CMD_VDEV_RESET 0x33 @@ -244,9 +245,11 @@ static unsigned long get_airq_indicator(struct virtqueue *vqs[], int nvqs, unsigned long bit, flags; for (i = 0; i < MAX_AIRQ_AREAS && !indicator_addr; i++) { + mutex_lock(&airq_areas_lock); if (!airq_areas[i]) airq_areas[i] = new_airq_info(); info = airq_areas[i]; + mutex_unlock(&airq_areas_lock); if (!info) return 0; write_lock_irqsave(&info->lock, flags); -- 2.20.1