Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9040999pxu; Mon, 28 Dec 2020 05:11:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmV1KPXxawF4fz9z4tePFOE3LmJ8dmfSVJQYchRX5EMNrG/4xEKFpV3dx28ErpBmExanbq X-Received: by 2002:a50:f745:: with SMTP id j5mr41511493edn.92.1609161082824; Mon, 28 Dec 2020 05:11:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161082; cv=none; d=google.com; s=arc-20160816; b=sBVFpYBkV8+KOiav3Jf/2qF80iwyoisvx70C6/TrL9FH2jVe4iaFsU2BzOr08CCqvK Rs9r+VlBHWyoYy+jqGvqsTRMuWOkdat6G2fYY7yb6czJxkDWaCj7sfk8W4oRxopbLxHC CWik/klSN2j+4PNoTTWiMK3Q2lCVWdrcmpNs2G95YMt70AHicyg7yAFXv7tojPCSFnta DWUdP5QYIlcq4Cp2TebSb5ToouxzmSSndSCGSCap15z7X8GjSydgz6fCgaM/PpryMxrz iYutjCz9isUJQuKTFPFP1cZjw0m+MUG0FDvipyYjUFGf2/hJp1NQ1avfUplh/l7DvhPL rxQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wL6x3IKA2UxAIOzbfScs9tGKz/yEaB53K6K0j74Qf+Q=; b=aPyBT4C0e8iUFl3QgkwxNG4IM+YfhTpxIKx3WEDrD8BAGhRz/gybLqh6elqOpxytSz rAhwZYQaf2pJMtMS8W3ertF6FEtuwPvrRsxiyMxKc2kEv11yn3nt0J6KriAnkCmQdGQ1 XrrhS1zeVLpOWJHdhTgxyKu0phzbQmhlEOuY4yTXLeg3c3GOIqbj6y8uFTE/LZUPMgOD oaXq39mdvEWpV98Rym/7T14R+nAQgME3+E237NYAak+BywnZMFdGkmKCpXKkHHtWtIVl rkuqXV0L2e7W62N8DBfO4VGaGKwp6OeiIMJCG8mIuq+bxTc7VvX7KMGONB/DP5VL3IXk YdHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EwyiQaqU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca6si19650678edb.504.2020.12.28.05.11.00; Mon, 28 Dec 2020 05:11:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EwyiQaqU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729376AbgL1NHe (ORCPT + 99 others); Mon, 28 Dec 2020 08:07:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:33448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729829AbgL1NFn (ORCPT ); Mon, 28 Dec 2020 08:05:43 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id ADFB7208D5; Mon, 28 Dec 2020 13:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160702; bh=RD+4gNf0fKUzEDW/Yl9NecqLk1rl32n6y7pUiwD/Mwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EwyiQaqUgBZCE2VTVDGMC5+rUqQMtLLxhuoyNCoHFhqOmnabeTMHfxTQBQfTczS1u WnMPtCWIsN+xSM2RIJW0O7k+DTQI/wuV7oBhb9uI3q9V/fQjF04gMW27WkNU45te/p ixRJuTKQysz8gUVo0TcbsLGnSXxmpbbnCCpFSYLY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Haberland , Jan Hoeppner , Jens Axboe Subject: [PATCH 4.9 141/175] s390/dasd: fix list corruption of lcu list Date: Mon, 28 Dec 2020 13:49:54 +0100 Message-Id: <20201228124900.083389309@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Haberland commit 53a7f655834c7c335bf683f248208d4fbe4b47bc upstream. In dasd_alias_disconnect_device_from_lcu the device is removed from any list on the LCU. Afterwards the LCU is removed from the lcu list if it does not contain devices any longer. The lcu->lock protects the lcu from parallel updates. But to cancel all workers and wait for completion the lcu->lock has to be unlocked. If two devices are removed in parallel and both are removed from the LCU the first device that takes the lcu->lock again will delete the LCU because it is already empty but the second device also tries to free the LCU which leads to a list corruption of the lcu list. Fix by removing the device right before the lcu is checked without unlocking the lcu->lock in between. Fixes: 8e09f21574ea ("[S390] dasd: add hyper PAV support to DASD device driver, part 1") Cc: stable@vger.kernel.org Signed-off-by: Stefan Haberland Reviewed-by: Jan Hoeppner Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/s390/block/dasd_alias.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/s390/block/dasd_alias.c +++ b/drivers/s390/block/dasd_alias.c @@ -255,7 +255,6 @@ void dasd_alias_disconnect_device_from_l return; device->discipline->get_uid(device, &uid); spin_lock_irqsave(&lcu->lock, flags); - list_del_init(&device->alias_list); /* make sure that the workers don't use this device */ if (device == lcu->suc_data.device) { spin_unlock_irqrestore(&lcu->lock, flags); @@ -282,6 +281,7 @@ void dasd_alias_disconnect_device_from_l spin_lock_irqsave(&aliastree.lock, flags); spin_lock(&lcu->lock); + list_del_init(&device->alias_list); if (list_empty(&lcu->grouplist) && list_empty(&lcu->active_devices) && list_empty(&lcu->inactive_devices)) {