Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2301031rwd; Wed, 14 Jun 2023 00:27:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qP9ctgnnUqDvm1Qnfbu+vEEkh99/I1yOBfFh6dKu7VVQrhFN019WHMOOD45dFqfTWJTvP X-Received: by 2002:a05:6402:455:b0:510:ddad:fae6 with SMTP id p21-20020a056402045500b00510ddadfae6mr9037859edw.3.1686727631028; Wed, 14 Jun 2023 00:27:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686727631; cv=none; d=google.com; s=arc-20160816; b=JmURN/qhGjRMTm89DjufNCvSeON7I7EQyCR/YXwLj+JIkAIkOebX83JW6kwbyEY3C5 crSZT2RDoC2gC2NGEPc0rSrUXwbjCUwuMR++QzC5hndQMvtEg8e4BQiv7DyZme+Cnj4A qbbQXu8z0/1J/eW6Mjpt/tpENRsKGH91fUDSW9sNmR8ZUGoqFsX3gTT3gGnVyb91SaTO mFYsxS+ZqynK8Hb0Fh6U3ggel7a2k2q/r17vqTS0xTUGgtafqim1cRUu2YdJWasN0+LZ 0oKOEh+6g9+V/Vcd8CDLQ6+xydIZe0URTcseFLzKP0baXYGzDW5Co0F/FvsEUuIK7D2F 92Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oa4DOgSZwpr5FlHNC7X1lgn1eoGAQfcjs1SrNJbVpTg=; b=UeoKDKWpRviwwBjmthCarcpEjcej9BUumLvUuYMyYB0VEanC3mAK8AwKfxpnIqhPcH KMgDmD+OjjrdVKutECOgxFzxf++Q74gm1vphbGO/qfru4fwwCMSdyOQHuS2b/oUA1A4C HbQ4Ew50nuAnQEX7w7uAjHMTBGhre8vuBcetCaow7WF/ZGK4A4jT38wwODYAbw9Ru2Mw 6eP7sFcJ0BB8YKqcGSf4L5ruxLxn7da07Jw2j7w9A3wk1Bw/pfbstTOOJMijX9AzZYym aZF+J04KRGR7+8LX3Y807EF4S71WYh0Up7pfVpy0Sfcy1AD0urq55fC114cTDIwlz1ua UhuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=hHT9ZAx1; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a50eaca000000b005187b839211si1132086edp.533.2023.06.14.00.26.42; Wed, 14 Jun 2023 00:27:11 -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=@infradead.org header.s=bombadil.20210309 header.b=hHT9ZAx1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243489AbjFNHYf (ORCPT + 99 others); Wed, 14 Jun 2023 03:24:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243202AbjFNHYJ (ORCPT ); Wed, 14 Jun 2023 03:24:09 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 869A426A0; Wed, 14 Jun 2023 00:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oa4DOgSZwpr5FlHNC7X1lgn1eoGAQfcjs1SrNJbVpTg=; b=hHT9ZAx1PTiGPKAhnhqP1Wfk0i gl/+ELIbVzYi5aXI1kQPrGZT96YPRBF6A6Q7Js1mZev89Tt+WQpCZIcUJDbkCkNKYX/ty67ZCP5/P xoJqBWhbwkQav79q7n1SdUb6wTcMTdmC9e+2NSFUl99xYNPRAsRaQAGirQTj9uQY3mOibluV2sY1L AIlwwJo/zRDSagW0sI9yDcUMOwZBIJ5Y2aOBzK7ZTio+Klw1348reyBx3oaf2Bw1gr8gOVe9sTVbe byFTWDgVz7bOlLr3OX/XR+jBRRciFXAxJf2eEzKxWJCHrWF6gj4LWBgLTh4iMAQc416FZGai/enI5 xyH6aaMg==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q9Kpy-00AeEL-0l; Wed, 14 Jun 2023 07:22:38 +0000 Date: Wed, 14 Jun 2023 00:22:38 -0700 From: Christoph Hellwig To: Ayush Jain Cc: sfr@canb.auug.org.au, Linux Kernel Mailing List , Linux Next Mailing List , Wyes Karny , hch@infradead.org, Jens Axboe , linux-block@vger.kernel.org Subject: Re: Kernel null pointer dereference on stopping raid device Message-ID: References: <3c4911c4-d3d7-a93e-5f14-e97384ae4f21@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3c4911c4-d3d7-a93e-5f14-e97384ae4f21@amd.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Hi Ayush, can you try this patch? diff --git a/drivers/md/md.c b/drivers/md/md.c index ca0de7ddd9434d..828c4e6b9c5013 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2460,7 +2460,7 @@ static void export_rdev(struct md_rdev *rdev, struct mddev *mddev) if (test_bit(AutoDetected, &rdev->flags)) md_autodetect_dev(rdev->bdev->bd_dev); #endif - blkdev_put(rdev->bdev, mddev->major_version == -2 ? &claim_rdev : rdev); + blkdev_put(rdev->bdev, &claim_rdev); rdev->bdev = NULL; kobject_put(&rdev->kobj); } @@ -3644,7 +3644,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe goto out_clear_rdev; rdev->bdev = blkdev_get_by_dev(newdev, BLK_OPEN_READ | BLK_OPEN_WRITE, - super_format == -2 ? &claim_rdev : rdev, NULL); + &claim_rdev, NULL); if (IS_ERR(rdev->bdev)) { pr_warn("md: could not open device unknown-block(%u,%u).\n", MAJOR(newdev), MINOR(newdev)); @@ -3681,7 +3681,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe return rdev; out_blkdev_put: - blkdev_put(rdev->bdev, super_format == -2 ? &claim_rdev : rdev); + blkdev_put(rdev->bdev, &claim_rdev); out_clear_rdev: md_rdev_clear(rdev); out_free_rdev: