All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
@ 2026-05-10  4:23 ` Deepanshu Kartikey
  0 siblings, 0 replies; 12+ messages in thread
From: Deepanshu Kartikey @ 2026-05-10  4:23 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: Deepanshu Kartikey, stable, syzbot+eec8f2693d71386bd600,
	linux-kernel, linux-f2fs-devel

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 <kartikey406@gmail.com>
---
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



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
@ 2026-05-10  4:23 ` Deepanshu Kartikey
  0 siblings, 0 replies; 12+ messages in thread
From: Deepanshu Kartikey @ 2026-05-10  4:23 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: linux-f2fs-devel, linux-kernel, Deepanshu Kartikey, stable,
	syzbot+eec8f2693d71386bd600

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 <kartikey406@gmail.com>
---
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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
  2026-05-10  4:23 ` Deepanshu Kartikey
@ 2026-05-11  1:41   ` patchwork-bot+f2fs
  -1 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+f2fs--- via Linux-f2fs-devel @ 2026-05-11  1:41 UTC (permalink / raw)
  To: Deepanshu Kartikey
  Cc: linux-kernel, linux-f2fs-devel, jaegeuk,
	syzbot+eec8f2693d71386bd600, stable

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Sun, 10 May 2026 09:53:36 +0530 you 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:
> 
> [...]

Here is the summary with links:
  - [f2fs-dev,v2] f2fs: initialize ino_entry_info before checkpoint load
    https://git.kernel.org/jaegeuk/f2fs/c/16c55b3147cc

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html




_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
@ 2026-05-11  1:41   ` patchwork-bot+f2fs
  0 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+f2fs @ 2026-05-11  1:41 UTC (permalink / raw)
  To: Deepanshu Kartikey
  Cc: jaegeuk, chao, stable, syzbot+eec8f2693d71386bd600, linux-kernel,
	linux-f2fs-devel

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Sun, 10 May 2026 09:53:36 +0530 you 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:
> 
> [...]

Here is the summary with links:
  - [f2fs-dev,v2] f2fs: initialize ino_entry_info before checkpoint load
    https://git.kernel.org/jaegeuk/f2fs/c/16c55b3147cc

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
  2026-05-10  4:23 ` Deepanshu Kartikey
@ 2026-05-17  9:22   ` Chao Yu
  -1 siblings, 0 replies; 12+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-05-17  9:22 UTC (permalink / raw)
  To: Deepanshu Kartikey, jaegeuk
  Cc: stable, syzbot+eec8f2693d71386bd600, linux-kernel,
	linux-f2fs-devel

On 5/10/2026 12:23 PM, 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 <kartikey406@gmail.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
@ 2026-05-17  9:22   ` Chao Yu
  0 siblings, 0 replies; 12+ messages in thread
From: Chao Yu @ 2026-05-17  9:22 UTC (permalink / raw)
  To: Deepanshu Kartikey, jaegeuk
  Cc: chao, linux-f2fs-devel, linux-kernel, stable,
	syzbot+eec8f2693d71386bd600

On 5/10/2026 12:23 PM, 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 <kartikey406@gmail.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
  2026-05-10  4:23 ` Deepanshu Kartikey
@ 2026-06-21  8:18   ` Deepanshu Kartikey
  -1 siblings, 0 replies; 12+ messages in thread
From: Deepanshu Kartikey @ 2026-06-21  8:18 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: stable, syzbot+eec8f2693d71386bd600, linux-kernel,
	linux-f2fs-devel

On Sun, May 10, 2026 at 9:53 AM Deepanshu Kartikey
<kartikey406@gmail.com> 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 <kartikey406@gmail.com>
> ---
> 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.

Please let me know if anything needed from my side.

Thanks

Deepanshu Kartikey


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
@ 2026-06-21  8:18   ` Deepanshu Kartikey
  0 siblings, 0 replies; 12+ messages in thread
From: Deepanshu Kartikey @ 2026-06-21  8:18 UTC (permalink / raw)
  To: jaegeuk, chao
  Cc: linux-f2fs-devel, linux-kernel, stable,
	syzbot+eec8f2693d71386bd600

On Sun, May 10, 2026 at 9:53 AM Deepanshu Kartikey
<kartikey406@gmail.com> 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 <kartikey406@gmail.com>
> ---
> 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.

Please let me know if anything needed from my side.

Thanks

Deepanshu Kartikey

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
  2026-06-21  8:18   ` Deepanshu Kartikey
@ 2026-06-22  0:59     ` Chao Yu
  -1 siblings, 0 replies; 12+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2026-06-22  0:59 UTC (permalink / raw)
  To: Deepanshu Kartikey, jaegeuk
  Cc: stable, syzbot+eec8f2693d71386bd600, linux-kernel,
	linux-f2fs-devel

On 6/21/26 16:18, Deepanshu Kartikey wrote:
> On Sun, May 10, 2026 at 9:53 AM Deepanshu Kartikey
> <kartikey406@gmail.com> 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 <kartikey406@gmail.com>
>> ---
>> 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,

> 
> Please let me know if anything needed from my side.
> 
> Thanks
> 
> Deepanshu Kartikey



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
@ 2026-06-22  0:59     ` Chao Yu
  0 siblings, 0 replies; 12+ messages in thread
From: Chao Yu @ 2026-06-22  0:59 UTC (permalink / raw)
  To: Deepanshu Kartikey, jaegeuk
  Cc: chao, linux-f2fs-devel, linux-kernel, stable,
	syzbot+eec8f2693d71386bd600

On 6/21/26 16:18, Deepanshu Kartikey wrote:
> On Sun, May 10, 2026 at 9:53 AM Deepanshu Kartikey
> <kartikey406@gmail.com> 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 <kartikey406@gmail.com>
>> ---
>> 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,

> 
> Please let me know if anything needed from my side.
> 
> Thanks
> 
> Deepanshu Kartikey


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
  2026-06-22  0:59     ` Chao Yu
@ 2026-06-22 19:52       ` Jaegeuk Kim via Linux-f2fs-devel
  -1 siblings, 0 replies; 12+ messages in thread
From: Jaegeuk Kim @ 2026-06-22 19:52 UTC (permalink / raw)
  To: Chao Yu
  Cc: Deepanshu Kartikey, linux-f2fs-devel, linux-kernel, stable,
	syzbot+eec8f2693d71386bd600

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
> > <kartikey406@gmail.com> 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 <kartikey406@gmail.com>
> > > ---
> > > 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
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load
@ 2026-06-22 19:52       ` Jaegeuk Kim via Linux-f2fs-devel
  0 siblings, 0 replies; 12+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2026-06-22 19:52 UTC (permalink / raw)
  To: Chao Yu
  Cc: Deepanshu Kartikey, stable, syzbot+eec8f2693d71386bd600,
	linux-kernel, linux-f2fs-devel

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
> > <kartikey406@gmail.com> 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 <kartikey406@gmail.com>
> > > ---
> > > 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
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-06-22 19:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-10  4:23 [f2fs-dev] [PATCH v2] f2fs: initialize ino_entry_info before checkpoint load Deepanshu Kartikey
2026-05-10  4:23 ` Deepanshu Kartikey
2026-05-11  1:41 ` [f2fs-dev] " patchwork-bot+f2fs--- via Linux-f2fs-devel
2026-05-11  1:41   ` patchwork-bot+f2fs
2026-05-17  9:22 ` Chao Yu via Linux-f2fs-devel
2026-05-17  9:22   ` Chao Yu
2026-06-21  8:18 ` [f2fs-dev] " Deepanshu Kartikey
2026-06-21  8:18   ` Deepanshu Kartikey
2026-06-22  0:59   ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2026-06-22  0:59     ` Chao Yu
2026-06-22 19:52     ` Jaegeuk Kim
2026-06-22 19:52       ` [f2fs-dev] " Jaegeuk Kim via Linux-f2fs-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.