In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix to avoid uninit-value access in f2fs_sanity_check_node_footer
syzbot reported a f2fs bug as below:
BUG: KMSAN: uninit-value in f2fs_sanity_check_node_footer+0x374/0xa20fs/f2fs/node.c:1520f2fs_sanity_check_node_footer+0x374/0xa20fs/f2fs/node.c:1520f2fs_finish_read_bio+0xe1e/0x1d60fs/f2fs/data.c:177f2fs_read_end_io+0x6ab/0x2220 fs/f2fs/data.c:-1
bio_endio+0x1006/0x1160block/bio.c:1792submit_bio_noacct+0x533/0x2960block/blk-core.c:891submit_bio+0x57a/0x620block/blk-core.c:926blk_crypto_submit_bioinclude/linux/blk-crypto.h:203[inline]f2fs_submit_read_bio+0x12c/0x360fs/f2fs/data.c:557f2fs_submit_page_bio+0xee2/0x1450fs/f2fs/data.c:775read_node_folio+0x384/0x4b0fs/f2fs/node.c:1481__get_node_folio+0x5db/0x15d0fs/f2fs/node.c:1576f2fs_get_inode_folio+0x40/0x50fs/f2fs/node.c:1623do_read_inodefs/f2fs/inode.c:425[inline]f2fs_iget+0x1209/0x9380fs/f2fs/inode.c:596f2fs_fill_super+0x8f5a/0xb2e0fs/f2fs/super.c:5184get_tree_bdev_flags+0x6e6/0x920fs/super.c:1694get_tree_bdev+0x38/0x50fs/super.c:1717f2fs_get_tree+0x35/0x40fs/f2fs/super.c:5436vfs_get_tree+0xb3/0x5d0fs/super.c:1754fc_mountfs/namespace.c:1193[inline]do_new_mount_fcfs/namespace.c:3763[inline]do_new_mount+0x885/0x1dd0fs/namespace.c:3839path_mount+0x7a2/0x20b0fs/namespace.c:4159do_mountfs/namespace.c:4172[inline]__do_sys_mountfs/namespace.c:4361[inline]__se_sys_mount+0x704/0x7f0fs/namespace.c:4338__x64_sys_mount+0xe4/0x150fs/namespace.c:4338x64_sys_call+0x39f0/0x3ea0arch/x86/include/generated/asm/syscalls_64.h:166do_syscall_x64arch/x86/entry/syscall_64.c:63[inline]do_syscall_64+0x134/0xf80arch/x86/entry/syscall_64.c:94entry_SYSCALL_64_after_hwframe+0x77/0x7f
The root cause is: in f2fs_finish_read_bio(), we may access uninit data
in folio if we failed to read the data from device into folio, let's add
a check condition to avoid such issue.