Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp820863rwb; Mon, 26 Sep 2022 06:20:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM66KWtB6b+44MkEyGcAwSyvtfhWmnPKFnFKR45vKJ8Nb3u1HiLKstCSUNfQU5nqylgpX65D X-Received: by 2002:a63:a51e:0:b0:439:857:2758 with SMTP id n30-20020a63a51e000000b0043908572758mr19681078pgf.105.1664198417641; Mon, 26 Sep 2022 06:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198417; cv=none; d=google.com; s=arc-20160816; b=wJVEkhF46pY3Gt0BvDvvDFAOHN+q82kYIhG5YuXFypTvFRVl8l02wkvZe5dHEGe/A+ iLnaa+WFDuDs1ir3zs8mz9WEdRVft4VKiuu0x0rz8wV1pGt7RgTubUzxu5+GQrMguWzr eGfEHx4sph1GD3LIAZQz59PDgzS8DtwJG5GEk4xmRuuJ/hnF+XCdTS7HpLZpTjdqQh+u ougzXzRdJZ1X1X19W8SaIlhe7BXtd4g4n5jmPu/6BomrbqQoRbdMlSILtVMSX+eTADfZ lvNrBXVF5kR4ytb2aEHuo/aCruAdvbspuoVquBBbqGr9TcXZkVMiOFtKd+OAPFCUiVxV GVIw== 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=BR8sOzNPQXw89FlEvGkaVq3mAMS0TW63638sjmMel64=; b=cuGVgkKcy1gr2na7oaDUVgSaKiEGHfIIRCDfvuxOKEeB1u+FHCfOC1i1vN7VSr27W2 7fKhqhLNOdIrMr2AS2MtKN1+GQRktBrqqgX1LY9tGAxlwiIAaUACL4X/hg+R0uJn+X3k 9cNYjQcL+ynpIZeHQ4TUirOLvJUj6UNMDIy7TuxaPBT48vUdNo4tBWhVWLxIGgpGq5UI 898Hxr2ILHe02eAyTL0iaXe17qW7hUKtcO1vyh6A9rGZQR9bIogioEWT/D3hy8eIMZXt mM/p8Z/pkIKsBjQYUxP1+sKOAs2nAYFiMrv1vFLlSUcWXVbwTiAXTdry5YGPdW+p8Pr6 9NAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bIYqc2LM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a170902d2c700b0017555e9de54si11785897plc.427.2022.09.26.06.20.04; Mon, 26 Sep 2022 06:20:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bIYqc2LM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235855AbiIZKdY (ORCPT + 99 others); Mon, 26 Sep 2022 06:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235675AbiIZKc5 (ORCPT ); Mon, 26 Sep 2022 06:32:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 318C82250C; Mon, 26 Sep 2022 03:20:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 70F6960BAF; Mon, 26 Sep 2022 10:20:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6941EC433C1; Mon, 26 Sep 2022 10:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187602; bh=75DfJ5Yqg1z2SFT3L+O7MKMIFpGoOqNpgcehWq6lixc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bIYqc2LMs/2lqB3N8UKZJjg+8lXWEkC9iq9ffMP5rj6mP34SpAZJz91RbMdc3N+tA 51M+AHb3iycGfUMmuiFPhVtdeTJ8BcI5LgSP9ZpE1vUTu+gP/TvWx0p69xQZHM+6KI SBcFGmW6CxfSrojF9gIKhJ9Eqndl1AytlFq2tyy0= 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.19 52/58] s390/dasd: fix Oops in dasd_alias_get_start_dev due to missing pavgroup Date: Mon, 26 Sep 2022 12:12:11 +0200 Message-Id: <20220926100743.366856012@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Haberland commit db7ba07108a48c0f95b74fabbfd5d63e924f992d upstream. Fix Oops in dasd_alias_get_start_dev() function caused by the pavgroup pointer being NULL. The pavgroup pointer is checked on the entrance of the function but without the lcu->lock being held. Therefore there is a race window between dasd_alias_get_start_dev() and _lcu_update() which sets pavgroup to NULL with the lcu->lock held. Fix by checking the pavgroup pointer with lcu->lock held. Cc: # 2.6.25+ Fixes: 8e09f21574ea ("[S390] dasd: add hyper PAV support to DASD device driver, part 1") Signed-off-by: Stefan Haberland Reviewed-by: Jan Hoeppner Link: https://lore.kernel.org/r/20220919154931.4123002-2-sth@linux.ibm.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/s390/block/dasd_alias.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/s390/block/dasd_alias.c +++ b/drivers/s390/block/dasd_alias.c @@ -675,12 +675,12 @@ int dasd_alias_remove_device(struct dasd struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *base_device) { struct dasd_eckd_private *alias_priv, *private = base_device->private; - struct alias_pav_group *group = private->pavgroup; struct alias_lcu *lcu = private->lcu; struct dasd_device *alias_device; + struct alias_pav_group *group; unsigned long flags; - if (!group || !lcu) + if (!lcu) return NULL; if (lcu->pav == NO_PAV || lcu->flags & (NEED_UAC_UPDATE | UPDATE_PENDING)) @@ -697,6 +697,11 @@ struct dasd_device *dasd_alias_get_start } spin_lock_irqsave(&lcu->lock, flags); + group = private->pavgroup; + if (!group) { + spin_unlock_irqrestore(&lcu->lock, flags); + return NULL; + } alias_device = group->next; if (!alias_device) { if (list_empty(&group->aliaslist)) {