Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3344181pxf; Mon, 15 Mar 2021 07:35:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxWQnpTaNKVpMBrlLH5p/B4WTfZFdKvRSG1oBLNH+LBaPD4/07t6bKQelyFC08Xn3ulOU2 X-Received: by 2002:a17:907:4cf:: with SMTP id vz15mr23597297ejb.113.1615818947866; Mon, 15 Mar 2021 07:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615818947; cv=none; d=google.com; s=arc-20160816; b=wrn+1KZ826ysXfghHXRBeuiO/ryZhEh4Vs15H90LLhQgmF69nGzvC1HLZjs0K7h32F EchO+kevw17JreExyb+ePShCiXanQ1358N9H83W3rnggmKwr7iep3DK116Y1ELSihR7l jS0//UunZxZ8n+iwsOISohL+5c7KwEiPNlnrtKmdyfOivQrbHUjKMoevGfaQFPSu7F3a lVgFhOum4vAM97KtgjbQRs2eNtqNZryf89ax+JiSfNE/P3eVOYgavnJEyfHUnZDKqCa1 kF2SatYk+8uvVHDrTbUC7Tr9VLueqGF1fOU/YX1GozQzrr3zHKwriAeZ8bgcqiAu0EfV R1yw== 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=/WXMA2dW3K6ja910OWX+68IuZ4G29HpDI5rK+N2e6sE=; b=Ft5da1wzyIt+cozoX1paZGn5wkNLXYiPDVQ8UEUfPqKgAFZ1Ha5qi15Ni+xYGiftWu NJ5gCHgHCtepSGVoBhn7z1Fy70hF4tDzO7NNehQKstah/P755PTZPIn35gO2HcVv+ddB kSBfs8fw2+baBuwY1QcWc8IZqPuBrVB+RKUGJgyoV1FEspKvbX9Q4/Wo+7XF4lKxiwph 4NRkzuCY6dZGKgTGGbp7vYByBpVlITtf/7kfdf1SAMSptpsWFWD/QLyNxL1E7L2EApLi 7kBV0/uOi6W842BMqUvrPNbmHgHkDNDoPIzr7cjsTCI0FY3YojKbIjZRnyRjMg+m8u/A OciQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hyyip4fK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox25si11189543ejb.183.2021.03.15.07.35.25; Mon, 15 Mar 2021 07:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hyyip4fK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240146AbhCOOde (ORCPT + 99 others); Mon, 15 Mar 2021 10:33:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:37820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233279AbhCOOBV (ORCPT ); Mon, 15 Mar 2021 10:01:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 572FC64F5D; Mon, 15 Mar 2021 14:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816857; bh=l9t/jy+7hTt25NJiy8W2DlxlKVv9HV05Irxdw8Kn1YI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hyyip4fKh6x1vjHbjqEgzCs/mDp1cyZ9y5SnH+5JqZOZPS36ufI6xNlhN0XodbaTr n0CVjoWoTHTtyM+s/bNomZT9gGAY/keJm1V16nocVBRvNu8R9kq5yPFFiui867lna2 atV3rSKTWqzT2wn+pOMtgOARV+Q+BgSru2BRdd24= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Murphy Zhou , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 5.10 155/290] ext4: dont try to processed freed blocks until mballoc is initialized Date: Mon, 15 Mar 2021 14:54:08 +0100 Message-Id: <20210315135547.155524013@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Theodore Ts'o [ Upstream commit 027f14f5357279655c3ebc6d14daff8368d4f53f ] If we try to make any changes via the journal between when the journal is initialized, but before the multi-block allocated is initialized, we will end up deferencing a NULL pointer when the journal commit callback function calls ext4_process_freed_data(). The proximate cause of this failure was commit 2d01ddc86606 ("ext4: save error info to sb through journal if available") since file system corruption problems detected before the call to ext4_mb_init() would result in a journal commit before we aborted the mount of the file system.... and we would then trigger the NULL pointer deref. Link: https://lore.kernel.org/r/YAm8qH/0oo2ofSMR@mit.edu Reported-by: Murphy Zhou Reviewed-by: Jan Kara Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/super.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index ea5aefa23a20..e30bf8f342c2 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4876,7 +4876,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); - sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; sbi->s_journal->j_submit_inode_data_buffers = ext4_journal_submit_inode_data_buffers; sbi->s_journal->j_finish_inode_data_buffers = @@ -4993,6 +4992,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto failed_mount5; } + /* + * We can only set up the journal commit callback once + * mballoc is initialized + */ + if (sbi->s_journal) + sbi->s_journal->j_commit_callback = + ext4_journal_commit_callback; + block = ext4_count_free_clusters(sb); ext4_free_blocks_count_set(sbi->s_es, EXT4_C2B(sbi, block)); -- 2.30.1