Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525929pxf; Mon, 15 Mar 2021 11:30:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHPWeo2pExeDh78kYZt8Dxr2GwGVdST8mxk6U1Tly4cGGgTTg3k6/4pjR1SyVyK98zWEM4 X-Received: by 2002:a17:906:b20b:: with SMTP id p11mr25639991ejz.0.1615833041658; Mon, 15 Mar 2021 11:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833041; cv=none; d=google.com; s=arc-20160816; b=cGwtH+ZVypB+78/9lv6ZxyL6MkIEi4hzHLKkTcG+KnF+1QeACP1lqsPo8L8R1Eg1Hv YD26Rqw/WkI6265drDaMg6gdGI64tzHjDxP9zBO1+jg7KSgYzGOXoBEeV089uRh1APl3 8sPfUW25MZ24Ifs9EfK69XDopTfN7CW/k8p/Tk/E9QACAWDdykZnCqAtMZjTzryqDisl sSfwcROn+MH7FCfr4ZXMT5sEBYdWe4tJX5RPjc8eWX/YibgcUElerMnZ6SxN5Hfx04+k dIk/1dM29I7+7BVgenLNFP/TNsYwIxIQx16SDfWzsGTx4j0qB0s75LwF3dJ1ZLLgMnnq ZV0A== 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=JNPpBwYW6Zesm3vVFbiApU7gLR6V36yx0AOO8ubRYYk=; b=QKCYVNjYQtC87/kX0p79eE1AVarWiYQgMfSJoUkVI81ksPzKW7b8KWAwX7/1Z00pZc ug/IsVo09Wb/vLTqhmLWrUH48R4P9umxYadSsuUG7pGWIlVswZYmIq//U0pkCmJIM7T+ pnkoC2y5Hvb+0LxZPea0UUqNTuB04BYVRYB3VuNWntae1hSqk7bRY/44hcYrs/M+CoVh HRprR8HeSPzHSHOyBtC3pmZO6b/bIMo50z0KqXPe7WV857u+QgGQjYneLdtZI3/+Wk9b Mb+RIvSKy7DkW1nngLAM9v9HJNupU40F2dPfNw+Qq6LER44fCLno2Sv7/jeGpzcxOLvV SIRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RyGcinZs; 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 m15si12456863edj.170.2021.03.15.11.29.57; Mon, 15 Mar 2021 11:30:41 -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=RyGcinZs; 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 S239615AbhCOOcs (ORCPT + 99 others); Mon, 15 Mar 2021 10:32:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:37836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233158AbhCOOAz (ORCPT ); Mon, 15 Mar 2021 10:00:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 46DB564F12; Mon, 15 Mar 2021 14:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816831; bh=b13n/JM383bPTPMveV85jOVeUCq/BvkKO7g6EFlCcMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RyGcinZsLFGmU46escI3n2Q1zds/KZcqa+jBfui2cQDNeJTbLfx5rFRdZzKU6HQQS Diwh+XjilxdmYeIr4sDM3YfQXW71eS/o0xXvUL3Z2soi8De8BI8I5lLuAL8maVw35R z8ePe3aefaPN+Wk90nZz1bO8M0h2pt8OkEGQtx38= 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.11 151/306] ext4: dont try to processed freed blocks until mballoc is initialized Date: Mon, 15 Mar 2021 14:53:34 +0100 Message-Id: <20210315135512.744888708@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 9a6f9875aa34..2ae0af1c88c7 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4875,7 +4875,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 = @@ -4987,6 +4986,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