In the Linux kernel, the following vulnerability has been resolved:
hfs: fix to initialize fields of hfs_inode_info after hfs_alloc_inode()
Syzbot reports uninitialized value access issue as below:
loop0: detected capacity change from 0 to 64
=====================================================BUG: KMSAN: uninit-value in hfs_revalidate_dentry+0x307/0x3f0fs/hfs/sysdep.c:30hfs_revalidate_dentry+0x307/0x3f0fs/hfs/sysdep.c:30d_revalidatefs/namei.c:862[inline]lookup_fast+0x89e/0x8e0fs/namei.c:1649walk_componentfs/namei.c:2001[inline]link_path_walk+0x817/0x1480fs/namei.c:2332path_lookupat+0xd9/0x6f0fs/namei.c:2485filename_lookup+0x22e/0x740fs/namei.c:2515user_path_at_empty+0x8b/0x390fs/namei.c:2924user_path_atinclude/linux/namei.h:57[inline]do_mountfs/namespace.c:3689[inline]__do_sys_mountfs/namespace.c:3898[inline]__se_sys_mount+0x66b/0x810fs/namespace.c:3875__x64_sys_mount+0xe4/0x140fs/namespace.c:3875do_syscall_x64arch/x86/entry/common.c:52[inline]do_syscall_64+0xcf/0x1e0arch/x86/entry/common.c:83entry_SYSCALL_64_after_hwframe+0x63/0x6bBUG: KMSAN: uninit-value in hfs_ext_read_extent fs/hfs/extent.c:196[inline]BUG: KMSAN: uninit-value in hfs_get_block+0x92d/0x1620fs/hfs/extent.c:366hfs_ext_read_extentfs/hfs/extent.c:196[inline]hfs_get_block+0x92d/0x1620fs/hfs/extent.c:366block_read_full_folio+0x4ff/0x11b0fs/buffer.c:2271hfs_read_folio+0x55/0x60fs/hfs/inode.c:39filemap_read_folio+0x148/0x4f0mm/filemap.c:2426do_read_cache_folio+0x7c8/0xd90mm/filemap.c:3553do_read_cache_pagemm/filemap.c:3595[inline]read_cache_page+0xfb/0x2f0mm/filemap.c:3604read_mapping_pageinclude/linux/pagemap.h:755[inline]hfs_btree_open+0x928/0x1ae0fs/hfs/btree.c:78hfs_mdb_get+0x260c/0x3000fs/hfs/mdb.c:204hfs_fill_super+0x1fb1/0x2790fs/hfs/super.c:406mount_bdev+0x628/0x920fs/super.c:1359hfs_mount+0xcd/0xe0fs/hfs/super.c:456legacy_get_tree+0x167/0x2e0fs/fs_context.c:610vfs_get_tree+0xdc/0x5d0fs/super.c:1489do_new_mount+0x7a9/0x16f0fs/namespace.c:3145path_mount+0xf98/0x26a0fs/namespace.c:3475do_mountfs/namespace.c:3488[inline]__do_sys_mountfs/namespace.c:3697[inline]__se_sys_mount+0x919/0x9e0fs/namespace.c:3674__ia32_sys_mount+0x15b/0x1b0fs/namespace.c:3674do_syscall_32_irqs_onarch/x86/entry/common.c:112[inline]__do_fast_syscall_32+0xa2/0x100arch/x86/entry/common.c:178do_fast_syscall_32+0x37/0x80arch/x86/entry/common.c:203do_SYSENTER_32+0x1f/0x30arch/x86/entry/common.c:246entry_SYSENTER_compat_after_hwframe+0x70/0x82Uninit was created at:__alloc_pages+0x9a6/0xe00mm/page_alloc.c:4590__alloc_pages_nodeinclude/linux/gfp.h:238[inline]alloc_pages_nodeinclude/linux/gfp.h:261[inline]alloc_slab_pagemm/slub.c:2190[inline]allocate_slabmm/slub.c:2354[inline]new_slab+0x2d7/0x1400mm/slub.c:2407___slab_alloc+0x16b5/0x3970mm/slub.c:3540__slab_allocmm/slub.c:3625[inline]__slab_alloc_nodemm/slub.c:3678[inline]slab_alloc_nodemm/slub.c:3850[inline]kmem_cache_alloc_lru+0x64d/0xb30mm/slub.c:3879alloc_inode_sbinclude/linux/fs.h:3018[inline]hfs_alloc_inode+0x5a/0xc0fs/hfs/super.c:165alloc_inode+0x83/0x440fs/inode.c:260new_inode_pseudofs/inode.c:1005[inline]new_inode+0x38/0x4f0fs/inode.c:1031hfs_new_inode+0x61/0x1010fs/hfs/inode.c:186hfs_mkdir+0x54/0x250fs/hfs/dir.c:228vfs_mkdir+0x49a/0x700fs/namei.c:4126do_mkdirat+0x529/0x810fs/namei.c:4149__do_sys_mkdiratfs/namei.c:4164[inline]__se_sys_mkdiratfs/namei.c:4162[inline]__x64_sys_mkdirat+0xc8/0x120fs/namei.c:4162do_syscall_x64arch/x86/entry/common.c:52[inline]do_syscall_64+0xcf/0x1e0arch/x86/entry/common.c:83entry_SYSCALL_64_after_hwframe+0x63/0x6b
It missed to initialize .tz_secondswest, .cached_start and .cached_blocks
fields in struct hfs_inode_info after hfs_alloc_inode(), fix it.