Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp174460lqo; Tue, 7 May 2024 16:41:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWw4+E45LKUeP4lI86Z+SAIyfWL4YqWDGX2UPW6CC8IAbyBXbS+nr3ypKad0L+35wyOtcf6cFDni0hZSKPB59vcnYdlNQ3oTzC5EYzI9g== X-Google-Smtp-Source: AGHT+IGKFK5qYix54YRGMRrwma87gBwdV4MNLpcFF6tUvbrWcAcKAoeilm6tn6TBu8SMCJUY6iJF X-Received: by 2002:a17:902:7608:b0:1e3:1526:77d5 with SMTP id d9443c01a7336-1eeb01a5fc9mr10518765ad.23.1715125269205; Tue, 07 May 2024 16:41:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715125269; cv=pass; d=google.com; s=arc-20160816; b=zUq43O9u6bDYcWLMsx17e85VK8sj+f8/sxApI1BtjzhOqENE2kzwRvPRxGFwb+JrtK +NrXEZm040OX931ZCatXkTx52nJKo6JGWLj5m8ZwUuEl5fquImvp4sULk3vvCjgQd2Um sPcZejEDSSqRJIFL3pdVsa937ZL0ty3i3qldD+Cf87sfd49wS0jwhBdymb0rVizsEVaj SQQ1E+iio1JLhu+g3T0EaEB0rItTW39bgvl4SulQMFGaiCrfZgbli/goUP5Ot7f5xKiK uhOg7xNSQLUgTvTehicc9yrCFoi2anz3hgknA1fGXmCzorWOUx3CziKcuCa0tPRizliN zCpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XZPda7z0134IJY41t0wBkyBlr2vqP8xFS3FL9xwBNL4=; fh=x4WfD+68fyTsfsCXoO3bslStEeE5yiGakwYLtBb5UfA=; b=Y4uf2EnbaKx9l13OjM89WJL5FGROYpDXzFFE8qwSVGdmxrXGqBqR2KdTp24vdlSUz0 OK7Jvnzd9OQdpZnnelQZ0Xd/fh925fyVANWqOoN6SAeePABERj6EAi87ptOWg3t4EnjD y2FQV71v44l5Bj2+uxDFv4z60k9FtedXaoOT8+DbU7ZrJpyvc5GHuKmX+WGzTCsUddSm mpeIVVWGcx/sYNeLFdZnmXaqYzWSAbsGUUyDC4asYabfM6kCqd3vwVYpv5egJH5K3Q2C 4SoNWjJGt7MVcwq7tDn5pEPIt0LJWbGPnKol+ok8Zp5fJ8TBiRu496Mlptq/wzRtKxZ3 Xp9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hqQkP0bB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q5-20020a170902dac500b001e28eb2a299si11668809plx.482.2024.05.07.16.41.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 16:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hqQkP0bB; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D28952861C2 for ; Tue, 7 May 2024 23:39:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D8FD14C5A1; Tue, 7 May 2024 23:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hqQkP0bB" 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 5742714C58C; Tue, 7 May 2024 23:11:14 +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=1715123474; cv=none; b=nufJ9yB7LkPq6PPlCs2q6cZLhdudzEgPhIXsjAH27XR/csX9znsuywK4Ii7JUDFroZ5D8lk5Gf1flS9dTacowTHgvb1NSj4KpQkkaGtLmr6ZQIvJ/XcNUdxirUR8cwtq4t0oEJ7nskYQe+JvHG58LWJYMkTbwSD854rRGiUKeio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123474; c=relaxed/simple; bh=vSS8ckXDKosjRvmfUEUfLwEc+gkRcWIIO5CcIp/zg/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j9sspROHXk9nnGGnklT81H9HLMwvWQcfmHvNJnZsFwbLSO1ASC+HK3W1mZr2U7uwfa69/35s9nzmUSDRkf0WCCEeVpCtzdTbs//ErNyTrLZ2k2WwTXtsLlxKPU9ZQsFcDxtt7vkb2mvhjKbMoLef0GcyCq5rzLS9Nc4bGEARUPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hqQkP0bB; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 218DEC4AF63; Tue, 7 May 2024 23:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715123474; bh=vSS8ckXDKosjRvmfUEUfLwEc+gkRcWIIO5CcIp/zg/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hqQkP0bBY+tGJ+vKdJPkp5Pjp/37CjTBX6gQnBys91pA5B5yQYHXc2K5Plcp610Xz XuKATXgnNIWpVwZ4azuwyfANM/bZJeRWnxkWjMwBXnc1/Iy+sIUxAO1Q0BMdLYxKKA HTVelDipo76nke+j6rmpVv8QAN/O3vpLk2pbIXcegygidL45Tx/tCwlWWwib10sKQi 5cNd9+NiysyI1rrdZk981ODCYoEEFdt9jAU6zySTSAGt/8W5ujBQqfvZjaRL7WqfWe ZiR4dJTBXgBp6b7wmgMtb/UfBGWGG54794OtyBjtaytfXbsnnyIDNlYehwmIsSHxrg 8aJdAmKUB+YtQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christian Brauner , Baokun Li , Jingbo Xu , Gao Xiang , Chao Yu , Sasha Levin , xiang@kernel.org, linux-erofs@lists.ozlabs.org Subject: [PATCH AUTOSEL 6.6 21/43] erofs: reliably distinguish block based and fscache mode Date: Tue, 7 May 2024 19:09:42 -0400 Message-ID: <20240507231033.393285-21-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507231033.393285-1-sashal@kernel.org> References: <20240507231033.393285-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.30 Content-Transfer-Encoding: 8bit From: Christian Brauner [ Upstream commit 7af2ae1b1531feab5d38ec9c8f472dc6cceb4606 ] 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: Sasha Levin --- fs/erofs/super.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index c9f9a43197db6..6a785b95121f1 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -796,17 +796,13 @@ static int erofs_init_fs_context(struct fs_context *fc) 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); -- 2.43.0