From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D665E233956 for ; Mon, 22 Jun 2026 19:52:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782157938; cv=none; b=pxtN1N5LzTjpsL+r8QDs7VApC+T/bTdo+0KyMkmJtz9ukqw86JKFHJc0XHTWOxUbxIKFHgKG+SnpTq5oP/l2FmfSq/rBheeD/ZxfglTF9gdMddp02Im9ZAYXD4dVcU1dxxJ46U6qyE4YAs5GhOvd7eLr35+ZMfav8h0TynrL8nQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782157938; c=relaxed/simple; bh=6h62ZjgWHQkNdOA4iJXHMDeqycoxvCqN0h7mtpbGe7o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aysmFZXJtCINiUDLLNzr6cLx46HVSdU25TFWpC0zKbWXOm075fwKYY7pf1QYTbt+MMRYK7/2KJIlWtnr31laOshAQIBq0xlKhh6p5lLy60qfd8S11co8PXSn0Ep6NExLosHh2HTUZLHrL0Pe1j6Yn82T8RET88eBHsNP3muxqgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aLH1zyEe; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aLH1zyEe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CE901F000E9; Mon, 22 Jun 2026 19:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782157937; bh=A5CPMd/xpnKIzj5zdrxz7lPo5mrrWBvT5DkNNKpntEo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=aLH1zyEe/nBHecxIh4UM7KQXJ/DFPF/r9jyWSgFoxcKir1j8jH4xuwNmD92B/mwBU BE/lbTLqjFiaThgPdFyx8m6LjrAd2ECW719NLUN1NwiDTewX63XMSfVhXPVbTj1DZ6 SRy/KbJn0BwAzae8JctDkUd1TCNnDrnsevyZeUkLazhqVzJG0yInDIF4FtwgxeFqL0 eTIslkousKrMNWayFh4qvi2jdskublFEhW350AUtAHug7g+EhI6FnLLWO1EvybZpRI eltJhHiHwRiVP4kuSO6OPJ9PPyafG46yT+PBRWciiscXTHEcjiHb3kyilAtkycYr7a 3NP4DIqC+wlBA== Date: Mon, 22 Jun 2026 19:52:15 +0000 From: Jaegeuk Kim To: Chao Yu Cc: Deepanshu Kartikey , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, stable@kernel.org, syzbot+eec8f2693d71386bd600@syzkaller.appspotmail.com Subject: Re: [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load Message-ID: References: <20260510042336.94751-1-kartikey406@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 06/22, Chao Yu wrote: > On 6/21/26 16:18, Deepanshu Kartikey wrote: > > On Sun, May 10, 2026 at 9:53 AM Deepanshu Kartikey > > wrote: > > > > > > When f2fs_get_valid_checkpoint() fails during mount (e.g. due to an > > > invalid checkpoint CRC on a malformed image), f2fs_fill_super() takes > > > an error path that eventually calls iput() on the root inode. This > > > invokes f2fs_drop_inode() -> f2fs_exist_written_data(), which acquires > > > sbi->im[]->ino_lock. However, f2fs_init_ino_entry_info() has not run > > > yet at this point, so the spinlock is uninitialized and lockdep > > > complains: > > > > > > F2FS-fs (loop0): invalid crc value > > > F2FS-fs (loop0): Failed to get valid F2FS checkpoint > > > INFO: trying to register non-static key. > > > The code is fine but needs lockdep annotation, or maybe > > > you didn't initialize this object before use? > > > ... > > > f2fs_exist_written_data+0x53/0x90 fs/f2fs/checkpoint.c:787 > > > f2fs_drop_inode+0xda/0xbf0 fs/f2fs/super.c:1852 > > > iput+0x651/0xe80 fs/inode.c:2009 > > > f2fs_fill_super+0x6047/0x7850 fs/f2fs/super.c:5461 > > > > > > Move f2fs_init_ino_entry_info() to before f2fs_get_valid_checkpoint() > > > so that sbi->im[] is always fully initialized before any error path > > > can trigger iput() -> f2fs_drop_inode(). The init function only > > > depends on raw superblock fields (BLKS_PER_SEG, F2FS_CP_PACKS, > > > NR_CURSEG_PERSIST_TYPE, __cp_payload), which are populated well > > > before checkpoint load, so the move is safe. > > > > > > Fixes: 3063c80776e3 ("f2fs: another way to set large folio by remembering inode number") > > > Cc: stable@kernel.org > > > Reported-by: syzbot+eec8f2693d71386bd600@syzkaller.appspotmail.com > > > Closes: https://syzkaller.appspot.com/bug?extid=eec8f2693d71386bd600 > > > Tested-by: syzbot+eec8f2693d71386bd600@syzkaller.appspotmail.com > > > Signed-off-by: Deepanshu Kartikey > > > --- > > > Changes in v2: > > > - Add Fixes: tag (suggested by Chao Yu) > > > - Add Cc: stable@kernel.org > > > --- > > > fs/f2fs/super.c | 9 +++++++-- > > > 1 file changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > > > index c6afdbd6e1cd..6a231a5b0d62 100644 > > > --- a/fs/f2fs/super.c > > > +++ b/fs/f2fs/super.c > > > @@ -5140,6 +5140,13 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc) > > > goto free_page_array_cache; > > > } > > > > > > + /* > > > + * Initialize ino entry info early so f2fs_drop_inode -> > > > + * f2fs_exist_written_data can safely take im->ino_lock if mount > > > + * fails after this point and triggers iput on cleanup. > > > + */ > > > + f2fs_init_ino_entry_info(sbi); > > > + > > > err = f2fs_get_valid_checkpoint(sbi); > > > if (err) { > > > f2fs_err(sbi, "Failed to get valid F2FS checkpoint"); > > > @@ -5184,8 +5191,6 @@ static int f2fs_fill_super(struct super_block *sb, struct fs_context *fc) > > > > > > f2fs_init_extent_cache_info(sbi); > > > > > > - f2fs_init_ino_entry_info(sbi); > > > - > > > f2fs_init_fsync_node_info(sbi); > > > > > > /* setup checkpoint request control and start checkpoint issue thread */ > > > -- > > > 2.43.0 > > > > > > > Hi Chao, > > > > Please let me know the status of this patch. This is already "Reviewed-by:" you. > > https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=065a6f8cd23a9297b543dcec913feb3cb787a25e > > It was merged, however, I think it should be reverted because commit 3063c80776e3 > ("f2fs: another way to set large folio by remembering inode number") was removed > from dev branch, we won't call f2fs_exist_written_data() from f2fs_drop_inode(). Thanks for heads-up. Let me drop this from -dev as emergency call, since the problemetic patch was not landed at all. > > Thanks, > > > > > Please let me know if anything needed from my side. > > > > Thanks > > > > Deepanshu Kartikey >