Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2293819pxp; Mon, 21 Mar 2022 16:07:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcYA1IDIOa7Ml52Ajaj5fqN4IUUCqpUEbHo58ylfQnyumJm5NUfoe/Pj+5QRON5KXSspUR X-Received: by 2002:a65:6082:0:b0:382:712b:56c7 with SMTP id t2-20020a656082000000b00382712b56c7mr7446160pgu.563.1647904030474; Mon, 21 Mar 2022 16:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647904030; cv=none; d=google.com; s=arc-20160816; b=0c6uAfz5xpFvysVhCgEvsR5EofUu8LZyMDdIZZ6hji0OvmG1Jczs5exQbvS3w6kQTC tx37sqORKBUozE8PxPQ7bOp+9t/yvaGqS7KNh+zvBo6zCXFTvR580TEp5Daob81WyvSY A3njLVW7NMIXmuoofLYdtJbHNDrF0VhZx06IZvMwJE+pWU+dO9dxIngo1dO/ex+lV3dJ LYLdMxrBwP+48mJf8/9At15jIbegRz89Hck1LVlviv8fJEQ3COYpOkxcbufRuNgUrcyv BDMDJxyz6aW/ntzTFxDgZv2dquaE6rhY8i1TAQLayinEtd1kyqK8UtjKyR14HCcCvj58 yU/A== 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=K5L9/MAKCbnGnM0QoJx2iW+w7J2TzjDzSMZ8hZ1ulXU=; b=ym8UqUJH02OrUfMBVDQHaGPlWZsVnEaVGImFaGv+up05blXEmG0iQ3Q/N0LLCCP8HF RYu/wdXazDuBJ3iDmcRDqBViLPSyPDshARb8piUhlfqZ8G6pS5n494ODzBqQpjuy5QoT fDd2wokZNTIzC1m/HnfuMrhtyu4FNuuk493YDklXx1C0fMiFRdtm4Kmxgau/meLigS5I +aUkoXquSzjT2JyMl4c/6bfH3tnHhOnjWODxGPBsiFvPEWa1ikiVbfHUh5D3b90XNqHZ VAR/d+l3NlaHhl2KJjXncLKanq3wnrHxqz5/I+DZ+6yaPTGvBaXYgmv2jKjBVc/+slte NEHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bb+45hAl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p13-20020a056a000b4d00b004fa3ad7918fsi2769506pfo.329.2022.03.21.16.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bb+45hAl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 D34DF357B6C; Mon, 21 Mar 2022 15:05:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348905AbiCUOFj (ORCPT + 99 others); Mon, 21 Mar 2022 10:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349169AbiCUN7d (ORCPT ); Mon, 21 Mar 2022 09:59:33 -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 3F83D22513; Mon, 21 Mar 2022 06:58:08 -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 E4A5FB81598; Mon, 21 Mar 2022 13:58:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F026C340E8; Mon, 21 Mar 2022 13:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871085; bh=9BTH4l2nUijaCftcHoyPmyiVcOiGnzGXNLmpimNUF+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bb+45hAll1IA8gcfZWTyCSDGj6YRLbDiC48Bg2aAFUpUcKPmIEUQQX+PUczEGNtX0 Yghpx0WfzalHN3AsWZmHGNCA3OPx64l/0Kaa8+RZ1DKR7bCFAXutUpPYGV3E3yzlxS Xm378gO3qlWu9pnJb3GU+R2Y1ObzoPO3/tSdJCGw= 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.4 02/17] ocfs2: fix crash when initialize filecheck kobj fails Date: Mon, 21 Mar 2022 14:52:38 +0100 Message-Id: <20220321133217.223599318@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133217.148831184@linuxfoundation.org> References: <20220321133217.148831184@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 @@ -1100,17 +1100,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) { @@ -1128,6 +1117,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