From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F2D214A633; Thu, 23 May 2024 13:22:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716470544; cv=none; b=kGtVwkcKrPhBOvJFhijF0xFNCZoy/DZ1pZjWF8DG+iFAAWJh+E+8lUayWGroKIUwfdzkxhgIxNg485hF6waCLmasfXZ7gtFd5ch7z85MLlaRIJHgqIvONHWV769jrLc8pEa3CmtPrLV8Z9CABKKhS2L5uV8qgJU65qJwIJ4C9vs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716470544; c=relaxed/simple; bh=HUaurkJiVusfUHbo+rjAA8T1xryVytzZ5sUAwbGsif4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uNkUyFbQUzuaE2+jNL+pzj1AeBovM+hyagl0erTTIgGA0+gU4Z5uETNxFqlY1X2w7AfGCBI3lpjEuvQ3XdDLhYg74fsFCfcpyVYs7I/0+P8I3bhBreBHwBlLRBzsQiWAITXtRmAHIq3yO9Z3dSKb+BgXz6yc54qyzYFivvbF6Jc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xucmw8nB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xucmw8nB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 274B6C3277B; Thu, 23 May 2024 13:22:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716470544; bh=HUaurkJiVusfUHbo+rjAA8T1xryVytzZ5sUAwbGsif4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xucmw8nB8KegvW0kjGT7CMJZaYqv0482PGb1bbZZqbVSV1EnE3s0CSg8j3Y5cUKbe VsVoV3+Vzci0snC6eVGF1or9Q+8522ihi6RqDgrkhedQBnJLj7T5/WVOGGJ14kl+5Q J5yjid7ANbNv+TsUDoXh5UhXE0L5IGp+nEfDoRAg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christian Brauner , Baokun Li , Jingbo Xu , Gao Xiang , Chao Yu Subject: [PATCH 6.8 09/23] erofs: reliably distinguish block based and fscache mode Date: Thu, 23 May 2024 15:13:36 +0200 Message-ID: <20240523130330.099973146@linuxfoundation.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240523130329.745905823@linuxfoundation.org> References: <20240523130329.745905823@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Brauner commit 7af2ae1b1531feab5d38ec9c8f472dc6cceb4606 upstream. When erofs_kill_sb() is called in block dev based mode, s_bdev may not have been initialised yet, and if CONFIG_EROFS_FS_ONDEMAND is enabled, it will be mistaken for fscache mode, and then attempt to free an anon_dev that has never been allocated, triggering the following warning: ============================================ ida_free called for id=0 which is not allocated. WARNING: CPU: 14 PID: 926 at lib/idr.c:525 ida_free+0x134/0x140 Modules linked in: CPU: 14 PID: 926 Comm: mount Not tainted 6.9.0-rc3-dirty #630 RIP: 0010:ida_free+0x134/0x140 Call Trace: erofs_kill_sb+0x81/0x90 deactivate_locked_super+0x35/0x80 get_tree_bdev+0x136/0x1e0 vfs_get_tree+0x2c/0xf0 do_new_mount+0x190/0x2f0 [...] ============================================ Now when erofs_kill_sb() is called, erofs_sb_info must have been initialised, so use sbi->fsid to distinguish between the two modes. Signed-off-by: Christian Brauner Signed-off-by: Baokun Li Reviewed-by: Jingbo Xu Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Link: https://lore.kernel.org/r/20240419123611.947084-3-libaokun1@huawei.com Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- fs/erofs/super.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -790,17 +790,13 @@ static int erofs_init_fs_context(struct static void erofs_kill_sb(struct super_block *sb) { - struct erofs_sb_info *sbi; + struct erofs_sb_info *sbi = EROFS_SB(sb); - if (erofs_is_fscache_mode(sb)) + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid) kill_anon_super(sb); else kill_block_super(sb); - sbi = EROFS_SB(sb); - if (!sbi) - return; - erofs_free_dev_context(sbi->devs); fs_put_dax(sbi->dax_dev, NULL); erofs_fscache_unregister_fs(sb);