Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2811860rwd; Wed, 14 Jun 2023 07:38:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7vZwU83zFO7L4/Cp8vPJ736KFCrSDsGr/r0sXc9CndQ27BFKmtqBYX/zjYDcbpEvQJVC91 X-Received: by 2002:a17:906:dac3:b0:96f:9608:da7c with SMTP id xi3-20020a170906dac300b0096f9608da7cmr17215381ejb.36.1686753530832; Wed, 14 Jun 2023 07:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753530; cv=none; d=google.com; s=arc-20160816; b=Z5nTuQ/tCXxn+5kppXM4XnihRhWJLoHFE7V+MLxHtXho/bKuyu0Kx5FMSsFgDjkVr/ L8+lyNYi7ztZkjKRqqC6x/ZMkLgB5p5h/xQvXKYAC7O2dQIjYaaL1mFXvc85SfCjAPGd Doh6f4DnlmdZQOKoC7geTZ5+YrC9x0F4M9Bu6/wnM+692XKV471oVCVpu7twncnTQLS0 5IkbkWHftS0B84+sSc8J55ZLfEwd1D7Z53afQ5ip+q8EJMmFdJvQHpru5SaA/dBMgxRf xp51unqe8+Af1Wif+i998hzRyocRSQnxQcCYLKWve/C6gQlpfE6xOnX8+Spk/16Uythp gheg== 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=cUPWTRyD6KgConRvc/LzTbU+jQN8JxfjvL3UpIyXkeM=; b=IUS566VBHFn67PKu/5kot3+6V/5cVI6AvwCziTqqdGcMnl5jj7ePDpdvhAZnuIiF/4 ufwv0xQi+OEECowLP10VTlKg33ll3V8yrtbbOfH6lENEcki6csSeBUSuH5XYjE3dUe5B cM3vakIsjn7DxxRqVTpNUZpcEVscpi0IWoI0F06q6wsO83GZ9krPQJVIn0//VJXP7HXa +todLpDLchhykIHxFXWExtFrCXm84g37McyHjw/j8DBXiu0eKhlJP35Jrp2ZAP+pZFBP NDoO8Np+CepXDMcDFpFDuQlMk/LVaRCapJBqTnsoaXh+LAYtghA9ZJnj5ROVsDy6lGVz pe0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=NodLVcgJ; 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 oq8-20020a170906cc8800b00977ca821ef2si8161086ejb.495.2023.06.14.07.38.25; Wed, 14 Jun 2023 07:38:50 -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=NodLVcgJ; 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 S245331AbjFNOB0 (ORCPT + 99 others); Wed, 14 Jun 2023 10:01:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245264AbjFNOBZ (ORCPT ); Wed, 14 Jun 2023 10:01:25 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E14219A; Wed, 14 Jun 2023 07:01:23 -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=cUPWTRyD6KgConRvc/LzTbU+jQN8JxfjvL3UpIyXkeM=; b=NodLVcgJ1NXwF37xa71v0LeCgL QwCltgPLEdPtIhwT7ovBuinlI+NjgDmuppsqrL5ZJwh4EknK7qM8znLme5kOfiJHpoji+aiYT9iDZ NdcrHcz0BNtrRJ679hKdInCKU7PuPxkrVRWrdIUFBLmyxf9+3CnyMTouyRP2493eMqUeiP410+G+2 /uFLTDI/Re80AMP9x20SHyQSeCAG3vW9mBib778IK9QDFs2WVH1rAaIhflvWk6XMrbR6eIkY9Qkcd 2IpaYW3w+oiKk7IBCM86K20Xo6Fj2kE0BX7RKUU73k2GjBI4Y6tYPm5mGDC/rLZ2lxLfz+V8VkOTG aqu6HM8w==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1q9R3p-00BqmJ-08; Wed, 14 Jun 2023 14:01:21 +0000 Date: Wed, 14 Jun 2023 07:01:20 -0700 From: Christoph Hellwig To: "Jain, Ayush" Cc: Christoph Hellwig , "sfr@canb.auug.org.au" , Linux Kernel Mailing List , Linux Next Mailing List , "Karny, Wyes" , Jens Axboe , "linux-block@vger.kernel.org" , "V, Narasimhan" , "Shetty, Kalpana" , "Shukla, Santosh" 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: 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 On Wed, Jun 14, 2023 at 09:54:07AM +0000, Jain, Ayush wrote: > Patch applied cleanly on next-20230614 and resolved the issue. > > Reported-by: Ayush Jain > Tested-by: Ayush Jain That was just a quick hack to verify the problem. I think this is the proper fix, can you try it as well? diff --git a/drivers/md/md.c b/drivers/md/md.c index ca0de7ddd9434d..da523e80a4e990 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2467,10 +2467,12 @@ static void export_rdev(struct md_rdev *rdev, struct mddev *mddev) static void md_kick_rdev_from_array(struct md_rdev *rdev) { - bd_unlink_disk_holder(rdev->bdev, rdev->mddev->gendisk); + struct mddev *mddev = rdev->mddev; + + bd_unlink_disk_holder(rdev->bdev, mddev->gendisk); list_del_rcu(&rdev->same_set); pr_debug("md: unbind<%pg>\n", rdev->bdev); - mddev_destroy_serial_pool(rdev->mddev, rdev, false); + mddev_destroy_serial_pool(mddev, rdev, false); rdev->mddev = NULL; sysfs_remove_link(&rdev->kobj, "block"); sysfs_put(rdev->sysfs_state); @@ -2488,7 +2490,7 @@ static void md_kick_rdev_from_array(struct md_rdev *rdev) INIT_WORK(&rdev->del_work, rdev_delayed_delete); kobject_get(&rdev->kobj); queue_work(md_rdev_misc_wq, &rdev->del_work); - export_rdev(rdev, rdev->mddev); + export_rdev(rdev, mddev); } static void export_array(struct mddev *mddev)