Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2303135pxp; Mon, 21 Mar 2022 16:22:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoCYVVq/OPig6ThRMoFDfc8lD5/fES7p4MdbJPfwByH1zAhwKflhg7tuyBFEuseUt5x34d X-Received: by 2002:a17:90b:1e0e:b0:1c7:5b03:1d8b with SMTP id pg14-20020a17090b1e0e00b001c75b031d8bmr311451pjb.121.1647904923300; Mon, 21 Mar 2022 16:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647904923; cv=none; d=google.com; s=arc-20160816; b=J2OEpgupDS3bHbpe4fQYSr+Mo2Jno7TOAFIckG7KGOZE9FHiKEPPM+hBz808bbW2Dq gGkp8f3k49WCVMbFxDkB/kMuIL5hovKs7/FRaZ3AiCbphojj80wokyEEuEiM52F1hXNZ +f36AWh6CuyWlbDXQSvl9jkCcidJk7zjWOZ1hvF0djv49J/0KXb3n1k1JZ8u578U2Cun t/KAVIzV+ctuFteQVxIW4lVzjYDWC4n4bT+muKEsqcmh91AV7XJ3vTkhiOmifpX87S2m epPn99ccOJW+TDZv17ZYcx/gZvpRQLBiz0Fd2Z4P+u7ETRYNJN5kAapDIGt205VwF7r1 N7+Q== 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=UtYXswKNJrBVj74TeVVNov0AYizs60h2tW2sI+VL3BY=; b=QiBRPRY8K1hSHRcEiimK4ZDBeiXy9OUKkweS+8Iu8yEKxh5mANjYYx87+ZDtinKR9q He4NY7n9sUX30KiXaItkDdZEsOCmRzAt0SBR4naYUb8dIKf88yQ+RPXK/NrvBKoPKvqZ PQo9hVWrfDBAyzUY4nK84S48YCuK4IPjDk/MEogqUlbfmnS/RxNVHWNwAskcQ6fiseiQ zbn31mJ4LayWckVELcaT2DRlnaY2209gRWeUKv9Q0Ii1Sy7ikDndrBvJbM7GZrw8Lvwj eciw/rwnkaXhSoFTnNaCZtK9aXNr0r5bh09nQ615MkVPmX5toCMmRGxnAveIrumLUH0J ROUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GU7kGdaj; 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 t21-20020a62ea15000000b004fa3a8e000esi8139375pfh.197.2022.03.21.16.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:22:03 -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=GU7kGdaj; 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 6F38438BB5B; Mon, 21 Mar 2022 15:21:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348730AbiCUOCg (ORCPT + 99 others); Mon, 21 Mar 2022 10:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348885AbiCUN6h (ORCPT ); Mon, 21 Mar 2022 09:58:37 -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 67CB31777D6; Mon, 21 Mar 2022 06:56:42 -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 0E6D1B816CE; Mon, 21 Mar 2022 13:56:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CEB1C340ED; Mon, 21 Mar 2022 13:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871000; bh=L3iDTjTDAzuYE7KT7FKragVUvH8KipAdzWbbl09LOjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GU7kGdajQjRNR8piiH1t/tVg56pR3OcacJ1WeoFSKfSquIvAJq7hL+W5LoP2Na2y2 Mp1K4da8UD99Zj+EdOcwppUBallXlV8rjPBh0xBjwc9PP+tV1Lg4rt7cYSdctE0Axs Dlf9+10D93uCvlTajeLRgLkbd23cpa3l21eklFU8= 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 4.19 46/57] ocfs2: fix crash when initialize filecheck kobj fails Date: Mon, 21 Mar 2022 14:52:27 +0100 Message-Id: <20220321133223.327033287@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133221.984120927@linuxfoundation.org> References: <20220321133221.984120927@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 @@ -1150,17 +1150,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) { @@ -1178,6 +1167,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