Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2220833iof; Tue, 7 Jun 2022 23:37:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsDVjifTAavJYDlOu8dFZ94X1JTEbznNbnbUG5Ipdo2zSJsrbFSfEPm35zDmbmCJqa9z9I X-Received: by 2002:a05:6a00:885:b0:510:950f:f787 with SMTP id q5-20020a056a00088500b00510950ff787mr98925349pfj.83.1654670267687; Tue, 07 Jun 2022 23:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654670267; cv=none; d=google.com; s=arc-20160816; b=riRGo1rAuo3tE/2CdlGLtqmJGt1MMx2+wvWsmYkfHc2/6Qz1EF69a0W7/i1AM9KHQV TB20iAU/P1dE48gurZMy4aveGD0XM95rMa/hZi2PCFzD5axMZzm1oR4hZqlOs2J1jQpf pa6Tbs6LJUoBEhncVb4mpgc7scx+wA/X40WlbQ/uzbo/0nBxc1g4ByVUWeCMfQFMwuvi tpogSRizpFD6BWm25nawGSIqo8BO0Gje9S1Qlvo/imbPrIqy38Uzl/iu1t0/ms2wrrLE uleYkgeyQE0tQfDBgldb6VxwuehRXh3tij70lZeZf2LH1BHEHX/q0K5q0vbHRdrkENTA VVdQ== 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=eSs4aNoW8wEvijONyG38eXxfqeJfd8yqVynAIHyAYR0=; b=Ir/jeXGd8WVZwEwlcUjs2kSRbBlaVjJ8rqD3bKZ2cjIcy/FzdyppTcDSe+6dEq4uw0 tzumeE3WDI+9gOtI8PqXeguwdRGeT4k1MnFFIpSgTNI8idOFpRfUvKC4bt4UzPNBg/gA wsF8S46mQWVAotcmPnuqyrTXEkFcIbNsXe04/r/eNL5WhwI5L0viRMYSS0fzXv1f3HlO jAuNXXbnJzy/5/zOkg2Goo6o2+brvzCZc3FqXgEmK/yazggN73f7RORYVh/TNoYzP+n5 K8rjeocfMAt2PNKQGaRKMWyr5XFxbVqeAikglvAgyCYuBziDKCvTuhyBJdg11f7jDCu/ qoGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xA+tovNw; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b20-20020a170902b61400b00161f01e76easi23845665pls.249.2022.06.07.23.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:37:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xA+tovNw; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ABFB5115A7B; Tue, 7 Jun 2022 23:00:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234109AbiFHCWh (ORCPT + 99 others); Tue, 7 Jun 2022 22:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1444878AbiFHCLa (ORCPT ); Tue, 7 Jun 2022 22:11:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0CCD2714A; Tue, 7 Jun 2022 12:25:49 -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 5E905609D0; Tue, 7 Jun 2022 19:25:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C95AC385A2; Tue, 7 Jun 2022 19:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629948; bh=K0bdUzOfeyMkxgs4pOZ4/dubG5F1GljN0qv8FWivZ/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xA+tovNwnjbKJv+jysR5q66+3Ck3+BwVWGFA7fNAt0h7K6w6b7Iw+qIE7FXC1Hh4B x2Hcr+p0ibXj8UvL+C27WOUlDGCBTzSjvpjN+LfU+tqxtYE44DNcyhkar4MYSYH41p Cu+AIbJV8sgcCt4+sbDKbG6XJ5mf7wBNuGHNi1ug= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fine Fan , Xiao Ni , Song Liu Subject: [PATCH 5.18 875/879] md: Dont set mddev private to NULL in raid0 pers->free Date: Tue, 7 Jun 2022 19:06:33 +0200 Message-Id: <20220607165028.255117406@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Xiao Ni commit 0f2571ad7a30ff6b33cde142439f9378669f8b4f upstream. In normal stop process, it does like this: do_md_stop | __md_stop (pers->free(); mddev->private=NULL) | md_free (free mddev) __md_stop sets mddev->private to NULL after pers->free. The raid device will be stopped and mddev memory is free. But in reshape, it doesn't free the mddev and mddev will still be used in new raid. In reshape, it first sets mddev->private to new_pers and then runs old_pers->free(). Now raid0 sets mddev->private to NULL in raid0_free. The new raid can't work anymore. It will panic when dereference mddev->private because of NULL pointer dereference. It can panic like this: [63010.814972] kernel BUG at drivers/md/raid10.c:928! [63010.819778] invalid opcode: 0000 [#1] PREEMPT SMP NOPTI [63010.825011] CPU: 3 PID: 44437 Comm: md0_resync Kdump: loaded Not tainted 5.14.0-86.el9.x86_64 #1 [63010.833789] Hardware name: Dell Inc. PowerEdge R6415/07YXFK, BIOS 1.15.0 09/11/2020 [63010.841440] RIP: 0010:raise_barrier+0x161/0x170 [raid10] [63010.865508] RSP: 0018:ffffc312408bbc10 EFLAGS: 00010246 [63010.870734] RAX: 0000000000000000 RBX: ffffa00bf7d39800 RCX: 0000000000000000 [63010.877866] RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffffa00bf7d39800 [63010.884999] RBP: 0000000000000000 R08: fffffa4945e74400 R09: 0000000000000000 [63010.892132] R10: ffffa00eed02f798 R11: 0000000000000000 R12: ffffa00bbc435200 [63010.899266] R13: ffffa00bf7d39800 R14: 0000000000000400 R15: 0000000000000003 [63010.906399] FS: 0000000000000000(0000) GS:ffffa00eed000000(0000) knlGS:0000000000000000 [63010.914485] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [63010.920229] CR2: 00007f5cfbe99828 CR3: 0000000105efe000 CR4: 00000000003506e0 [63010.927363] Call Trace: [63010.929822] ? bio_reset+0xe/0x40 [63010.933144] ? raid10_alloc_init_r10buf+0x60/0xa0 [raid10] [63010.938629] raid10_sync_request+0x756/0x1610 [raid10] [63010.943770] md_do_sync.cold+0x3e4/0x94c [63010.947698] md_thread+0xab/0x160 [63010.951024] ? md_write_inc+0x50/0x50 [63010.954688] kthread+0x149/0x170 [63010.957923] ? set_kthread_struct+0x40/0x40 [63010.962107] ret_from_fork+0x22/0x30 Removing the code that sets mddev->private to NULL in raid0 can fix problem. Fixes: 0c031fd37f69 (md: Move alloc/free acct bioset in to personality) Reported-by: Fine Fan Signed-off-by: Xiao Ni Signed-off-by: Song Liu Signed-off-by: Greg Kroah-Hartman --- drivers/md/raid0.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -361,7 +361,6 @@ static void free_conf(struct mddev *mdde kfree(conf->strip_zone); kfree(conf->devlist); kfree(conf); - mddev->private = NULL; } static void raid0_free(struct mddev *mddev, void *priv)