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 544F12F8EA2 for ; Sat, 9 May 2026 09:30:37 +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=1778319037; cv=none; b=cmdLQWPu1ZnAE5BwJz1EjCGmwiJdQ5GqPc60rndTh3eZ9sR+Ms40cLGKCPsjMi3h6dritgc/MbnLztbSBVNbtCVO/w237WPMSwd4wLXqS5FMpANxbfH4EGDyl5llVoln+Q6ocYqHCmOVJFETe724b9EG8cZvGBHG7FjG5odNvSY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778319037; c=relaxed/simple; bh=81b5WURI9fUNup/0VVB0CxlYR9cvtEduJLubXW0id3A=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=nenzmTLF0criz/AuicdVgJw32yTdZvgRMXtdKaIT4vTCZWKmsGGb3mThnSokU2z7P6A5/R1t0TjI3c5+hPvkiYmTlr8aDbi1I5giBgtpiGSsauXAsfYZB5UaJQ7qzSEtlJEbpiMNTJz5UNfylQz+/OvOSyIdyRuhLKqCCBWO+eg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NwLDJ2Nh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NwLDJ2Nh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 307C9C2BCB2; Sat, 9 May 2026 09:30:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778319036; bh=81b5WURI9fUNup/0VVB0CxlYR9cvtEduJLubXW0id3A=; h=Date:Cc:Subject:To:References:From:In-Reply-To:From; b=NwLDJ2NhBZj/PXvy0rQjnWeZsrp0PpwgOLArgfwRODtgpGgySGD+HwbZFylzSczU2 nP8ZWUSPP340Tku5svFI5h8ZmbrIYej3fOWjYPCgxol5gNKCYfgvJQqd/theHE5bG/ ZrU7gz3zIVUw7gVkwWXsTN3+wMgNk4ztvhIeAOogS6ewNX6NIyPNsEoYVAd9G42AUi rSxoSRmIaiQLTiO2aYZdMfL1rr8/JNUF0QPPNrwlYx7cBSTXzKLWVYwQiZkk2lnc7x icAt15E9NVZvWTKJDo/DXewcA+UmhhDW+TOZqtOxFHSmbUBrFGHEk0p7Do/CJoLNSm QYNpuK61nHsuw== Message-ID: Date: Sat, 9 May 2026 17:30:32 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+eec8f2693d71386bd600@syzkaller.appspotmail.com Subject: Re: [PATCH] f2fs: initialize ino_entry_info before checkpoint load To: Deepanshu Kartikey , jaegeuk@kernel.org References: <20260509042239.87763-1-kartikey406@gmail.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20260509042239.87763-1-kartikey406@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/9/26 12:22, 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. > Cc: stable@kernel.org Fixes: xxx Otherwise, it looks good to me. Thanks, > 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 > --- > 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 */