Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp169938lqo; Tue, 7 May 2024 16:28:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8Ud3yAzShPsvq/U0jpOhGlddGtE/KsTuy4wmHG2s+sVmKeN1GDYchhbBwRFj+89QtJY4YEksY7Pq2G4bUB0NVj0VxHpHW3VUqD7OwtA== X-Google-Smtp-Source: AGHT+IHq5abzpUR8/G8l+GNYknqgrhnqSH8iPhFOGBp2tT4utAcUXGINM+mXNJT6Dr/NKIDXsZFE X-Received: by 2002:a17:902:e882:b0:1e2:a807:7159 with SMTP id d9443c01a7336-1eeb0183885mr17427455ad.6.1715124518061; Tue, 07 May 2024 16:28:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715124518; cv=pass; d=google.com; s=arc-20160816; b=yIfgNsBlYFlCSOghqbFOFNqrsz4rGz1Kj7wh0aVOh1vPUsCT8gnmGCdiH+uR2Jutwy a9M8VfAXY/OAGrjDZlK+R3gypC2oOvFLduccYDmst7prhKO+wnWOuG+iFr/mFnLuned+ 1bZ7e22bVakscx2ihxvxwmNkTIX8fSue7ReD7TPSUbt6LN3vX2akt/+RbPuwaCprLZYq JXsyEKuNtDmdnjEqNLGci0tXIZoDZkhqlfyirquL1rgU0c5eg2Wl84HQqKymXaEt4Mp/ stGIWv9bMgiQW3biwlW1nw2wddf/YtM9A4AoGbhXCbdhCJqpXUclIGFhVuGOoilja0bt iRhA== 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=0ZOqv3qY1VL155P7ZnUK5jg6P1kqs2H2NhFlcmTIzO8=; fh=x4WfD+68fyTsfsCXoO3bslStEeE5yiGakwYLtBb5UfA=; b=DniSKCW9tMIIESGVt8LbxO69KkeCjAv/HEJ+2+cC37JTKD/8mhRFDW3fttonq5a0Tv uqkIVmPhjP2QR+fKsrl9pYiGze181aAmAtowWTVp3IF4l1BcuA01qbz0K070FCqHJMjv WIiOYeF0asbXLRcjs5YgTb+cFbl3EoVilxXnYbkSM3r3SJdahMeaOg3b90RFBk8M8+zm rxMRHa7zMbNMKG/HEhP8QvrXJyUaurfIWeHDjyPHKlljCLQmFAkZQwOtlTVLuc2qxCdu qNJ7v+LleQFqtyYkLkGM8Fc0Zq6cL6gAjjStJxg1QUYGwq1uPcGSFkVwZCYCUUeJjJ66 JN0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JbIzx5eJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172368-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 jg13-20020a17090326cd00b001ec60c157cdsi10569116plb.141.2024.05.07.16.28.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 16:28:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172368-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=JbIzx5eJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172368-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 6315D280D2C for ; Tue, 7 May 2024 23:28:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC36E13E8A4; Tue, 7 May 2024 23:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JbIzx5eJ" 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 1C95113E8B8; Tue, 7 May 2024 23:08:50 +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=1715123331; cv=none; b=lXAwEtGSBCLkGzq0F/ndt6KunJCXLJW+mDJHieLO6YJJ5GovhCjiAzVz87zmuezI23h91I1jAYiGBLrmSE7hkzXC219I3yKTeC7pJnkQIZAJPzCl5rh6Jx98SZT980LiNarIzFJz7xE6DTedHHlAi1J1d4VpogqN9S4is4PLjcg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715123331; c=relaxed/simple; bh=yqfzzvv4Vb9iFfLKiQtmvaF2w1b07asZiGiRgAATLho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ji8d2Gw2oCjdfuL2qMChINza7PHSpwQ1RjnBHFUU9LKzUk4PW0In0rYqcDcyLFOntT8algfhaVkeIKK1N/yfM7Ova5/6WFJgBmrFIBjtaQWzg3TMUzVFZatm8MTgfoNemIK6ijJFxceuIu1T4LuXyDoPYsjya2bZCktKK73BaMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JbIzx5eJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A19EEC2BBFC; Tue, 7 May 2024 23:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715123330; bh=yqfzzvv4Vb9iFfLKiQtmvaF2w1b07asZiGiRgAATLho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbIzx5eJKTFtd8mz8HF0R4R/P6SAOmLhIHt4kKOWURjuYoby+AnzZ8LRuBKzIY1wb Tk0Zs6dtIyXxYAGdFuWs5hoGGpzthL4lKN4Ft8sIvZEEda96aK+gdOHYuXkElXlJsq 4BFKfolgOVLVcQNH106WiswGC4138586ZMJuYLfUrc+Dy0rU+PNzoMrTYRyil3QL4a Wb5QtgQ7++6QvgwKrrZMPKqj4MyPBaxuGnbQI3BLF+JN89lVEZ97TO0Vqm+rF2NrUV 9aPqUAxnwuxdgVTzqFGAW/yjDg9Q4gxK/Jl1ed3DuHHY0YBSiWXsKcCYNQVF5yX9R6 jq1xLURwTtpcQ== 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.8 26/52] erofs: reliably distinguish block based and fscache mode Date: Tue, 7 May 2024 19:06:52 -0400 Message-ID: <20240507230800.392128-26-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240507230800.392128-1-sashal@kernel.org> References: <20240507230800.392128-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.8.9 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 24788c230b494..020495168b124 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -800,17 +800,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