Re: [PATCH] f2fs: don't BUG_ON an inconsistent node ino in roll-forward recovery

From: Chao Yu

Date: Tue Dec 01 2026 - 03:13:06 EST


On 11/25/26 15:39, Zhan Xusheng wrote:
> From: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
>
> do_recover_data() asserts that the ino in the NAT entry of the node it
> recovers into matches the ino in the footer of the fsynced node block.
> Both are read from disk and nothing checks one against the other
> before, so mounting an image with a wrong ino in that NAT entry hits
> the f2fs_bug_on(): a kernel BUG with CONFIG_F2FS_CHECK_FS, and without
> it a warning, after which the NAT ino is written into the footer of the
> recovered node.
>
> To reproduce, create a file, sync, write and fsync it, crash, and change
> the ino of the file's entry in the NAT journal of the checkpoint pack.
> The next mount gives:
>
> kernel BUG at fs/f2fs/recovery.c:698!
>
> Fail the recovery with -EFSCORRUPTED instead, as the ofs_of_node check
> right after it does.
>
> Reported-by: Guikun Yang <yangguikun19@xxxxxx>
> Closes: https://lore.kernel.org/all/tencent_5CEF90115E2715D386A8349FCA28D7D4D607@xxxxxx/
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
Reviewed-by: Chao Yu <chao@xxxxxxxxxx>

Thanks,