Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2279575pxp; Mon, 21 Mar 2022 15:44:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe7PPV6p2wlC8OetCP3QRDZjcV+kZaWAvINNK9Calu2RZ5ceGfmsI1D8kfvSVk6E180LbP X-Received: by 2002:a17:902:ce05:b0:14f:8ba2:2339 with SMTP id k5-20020a170902ce0500b0014f8ba22339mr15574005plg.152.1647902669335; Mon, 21 Mar 2022 15:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902669; cv=none; d=google.com; s=arc-20160816; b=tTRVponuwQroYck5+gLffOwYkoq75x2x2z2bDOKHZYssug/FwA5t4N1aN7ppt1nXX4 Hox2OdmKEyMkn81B8Bqf8CyJEkjiJbcRn6mMRJERgSg5cIu1ruMy2d6yeKXzD7x3ngYT LgfEEmuaj2r21B+k50/rik1RbPxwBpmTBex1yKGdlV8rQHpAngU2cysNwJzcoCwaaJlS bfMtV3gINre0pt9G+1t16vUExxw0o6q/bR8X7GJEnjkpoQ2ipc86NSQ7L/AYtXlIa6YR 4FH+TAF9V6s5vvqHYgP19oa93yTSKUPCX2fOqU4KHc7xosVoumuLJwOYzy0Ao9/N/IN3 Trcw== 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=zdQtw2C34YI3sMaeVSQkSfXXLyR5tgzmvv9uTw7kfUI=; b=1FXigAk/52jJtgQbvVThGjNFpP842FKWdjz6hyWbwtU0yjFs1rK1N9alt9+Hxm5lT/ G7EdvZoFTMW5TVPYAxqfJeTM5WNa/CxdcegkTugilm9In88gp4+efj7EgDjVpUOBN6MI AZZm2l+0+owtxGA0/TsrapIUa0fFnjCqk+Xc02SnBbpXVlAbirpqAA9qAoyB12JnXWQ+ iQgeGbLguj24bg+kQEDRcEBcdB8hk0P2VtvwHu6E2EN+vHoz526v1FGyMpuPsnmG8/Tr 2P+9PjZthuVMTStmG3HSri2KXVOYztBfLT7KO0IVDR27/FnzOutX0HZLzoUvqJ0F/Ij1 yw/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JxipW1hq; 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 j31-20020a634a5f000000b003816043f00bsi13640156pgl.512.2022.03.21.15.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:44:29 -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=JxipW1hq; 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 BB7FD3E06E1; Mon, 21 Mar 2022 14:53:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351277AbiCUOKu (ORCPT + 99 others); Mon, 21 Mar 2022 10:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349158AbiCUODZ (ORCPT ); Mon, 21 Mar 2022 10:03:25 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFB361770B3; Mon, 21 Mar 2022 07:00:30 -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 ams.source.kernel.org (Postfix) with ESMTPS id 49FCCB816C8; Mon, 21 Mar 2022 14:00:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D9C8C340E8; Mon, 21 Mar 2022 14:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871228; bh=1NvZWoJdlvPUkVw4Aq0oXH5wnc5kbY4fIKkcrvdEqtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxipW1hqYLTKn5ykdIl+d4ekTcxtqHroV+SNfilerNiGP1sgC/TdsOnSXhRWZWpzK NZZz+Ibbs8tUrSPiYmpnNbyS7bcSYaLZmDDSSkhWpcFG4EJTi2yATsliLiQ5JJqij1 rxGtIpr/+lInn4/9q10jmIM5oEyPFaasxD8QIgZ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Gang He , Jun Piao , Andrew Morton , Linus Torvalds Subject: [PATCH 5.15 02/32] ocfs2: fix crash when initialize filecheck kobj fails Date: Mon, 21 Mar 2022 14:52:38 +0100 Message-Id: <20220321133220.633365244@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133220.559554263@linuxfoundation.org> References: <20220321133220.559554263@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: Joseph Qi commit 7b0b1332cfdb94489836b67d088a779699f8e47e upstream. Once s_root is set, genric_shutdown_super() will be called if fill_super() fails. That means, we will call ocfs2_dismount_volume() twice in such case, which can lead to kernel crash. Fix this issue by initializing filecheck kobj before setting s_root. Link: https://lkml.kernel.org/r/20220310081930.86305-1-joseph.qi@linux.alibaba.com Fixes: 5f483c4abb50 ("ocfs2: add kobject for online file check") Signed-off-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Gang He Cc: Jun Piao Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/super.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1106,17 +1106,6 @@ static int ocfs2_fill_super(struct super goto read_super_error; } - root = d_make_root(inode); - if (!root) { - status = -ENOMEM; - mlog_errno(status); - goto read_super_error; - } - - sb->s_root = root; - - ocfs2_complete_mount_recovery(osb); - osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL, &ocfs2_kset->kobj); if (!osb->osb_dev_kset) { @@ -1134,6 +1123,17 @@ static int ocfs2_fill_super(struct super goto read_super_error; } + root = d_make_root(inode); + if (!root) { + status = -ENOMEM; + mlog_errno(status); + goto read_super_error; + } + + sb->s_root = root; + + ocfs2_complete_mount_recovery(osb); + if (ocfs2_mount_local(osb)) snprintf(nodestr, sizeof(nodestr), "local"); else