Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9046253pxu; Mon, 28 Dec 2020 05:19:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyj9257ys9tDqXWoFACXx2QgWMpPKpiQKiAs67f8mF2Qs6NO22CXnvR61esIhqUwK0o3Vz X-Received: by 2002:a17:906:4ec7:: with SMTP id i7mr1935023ejv.252.1609161571319; Mon, 28 Dec 2020 05:19:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161571; cv=none; d=google.com; s=arc-20160816; b=G5ykG2BsB6fIWkS6t+mh1NkFgYEiTgB3+lhumO/IDgSP0udu5YVRU9o0xvfcQ6i3Kj ejRqKzQMn3ubX85cOvNQcMpvSoZRh74grTqbMjETAx2lB1+lJ1fgpv0oBml040yNaIkB /+2dGJ5sMGM0Knl6TtKwjQXuhAQjGCq7MCPvk8E/XNpqeYAAzShX2DoB+PwPcal3X5wJ uWb171D4YR8svvxV/2jgblQO10Un5IB3cB1aoWgwTKeqE2H8WUPMRKsx7QkX+rkgbHw8 EQEDEQ+m5B5so0q0/Fv0JEvCa5iaIv58vG3ECLlc//tSIrkoyV18OA4bdT5KlFwS+lZc XVjA== 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=bKc3H4IFHbTZHJWeMk1tHfiBGEKlxZuj7lktVmhdWGE=; b=lillLV+f25XXUkJD0IZuVmambj7gva2HpLq4W0ch3CuJhSP0vyQFYEk2fYJ98k1fx+ /VtvnCRAIZrM6y29RauSgvNlMoRBUCyB2z3HC5mSljyICMD0d+97ZMvX6viG+cN4mlLI jPJD5CvA9eGCznhUVx8K8Jdcpf4LwW7bJUw4c6WiM6zx5onDa+qZy3zYPXiGZOpAl88b x2sjC7zl0F8KUHEH2Ez0EVA7dZd4nJTeOk0hPi+5LBYnCqiuUf9UPssogHhDXWUvHtG9 UBUqBzXczLvTZgsii895+cA0c925mIFlIDHvTyiKWNzVsfZIdRGGCB+lawCo63SDJLAs LhIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KTjwJMqa; 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 se3si17443802ejb.527.2020.12.28.05.19.07; Mon, 28 Dec 2020 05:19:31 -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=KTjwJMqa; 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 S2387428AbgL1NRM (ORCPT + 99 others); Mon, 28 Dec 2020 08:17:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:45354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731115AbgL1NRA (ORCPT ); Mon, 28 Dec 2020 08:17:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A3EFB207F7; Mon, 28 Dec 2020 13:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161380; bh=hZO3f+sU8DLpmWcx9RIoRxYScZUiG1znp4VtXoefxS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTjwJMqaKQqNjE4jXHDhtgcY/QF6Z1dGteEUPEgboRgAlF81TXDRKcPYqEangEUaF kJXdwwwUSlnDi8KibV27hiUpDnkQKDjI7hOsGoLaPA0Yi8w3B2EUz2FWuMw3HLixkm YWeATHRHO3gtnosApfWpKL1I/cU76KbMnZfNjrnQ= 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.14 194/242] s390/dasd: fix list corruption of lcu list Date: Mon, 28 Dec 2020 13:49:59 +0100 Message-Id: <20201228124914.231387489@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 @@ -256,7 +256,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); @@ -283,6 +282,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)) {