In the Linux kernel, the following vulnerability has been resolved:
net/9p: fix uninit-value in p9_client_rpc()
Syzbot with the help of KMSAN reported the following error:
BUG: KMSAN: uninit-value in trace_9p_client_res include/trace/events/9p.h:146[inline]BUG: KMSAN: uninit-value in p9_client_rpc+0x1314/0x1340net/9p/client.c:754trace_9p_client_resinclude/trace/events/9p.h:146[inline]p9_client_rpc+0x1314/0x1340net/9p/client.c:754p9_client_create+0x1551/0x1ff0net/9p/client.c:1031v9fs_session_init+0x1b9/0x28e0fs/9p/v9fs.c:410v9fs_mount+0xe2/0x12b0fs/9p/vfs_super.c:122legacy_get_tree+0x114/0x290fs/fs_context.c:662vfs_get_tree+0xa7/0x570fs/super.c:1797do_new_mount+0x71f/0x15e0fs/namespace.c:3352path_mount+0x742/0x1f20fs/namespace.c:3679do_mountfs/namespace.c:3692[inline]__do_sys_mountfs/namespace.c:3898[inline]__se_sys_mount+0x725/0x810fs/namespace.c:3875__x64_sys_mount+0xe4/0x150fs/namespace.c:3875do_syscall_64+0xd5/0x1f0entry_SYSCALL_64_after_hwframe+0x6d/0x75Uninit was created at:__alloc_pages+0x9d6/0xe70mm/page_alloc.c:4598__alloc_pages_nodeinclude/linux/gfp.h:238[inline]alloc_pages_nodeinclude/linux/gfp.h:261[inline]alloc_slab_pagemm/slub.c:2175[inline]allocate_slabmm/slub.c:2338[inline]new_slab+0x2de/0x1400mm/slub.c:2391___slab_alloc+0x1184/0x33d0mm/slub.c:3525__slab_allocmm/slub.c:3610[inline]__slab_alloc_nodemm/slub.c:3663[inline]slab_alloc_nodemm/slub.c:3835[inline]kmem_cache_alloc+0x6d3/0xbe0mm/slub.c:3852p9_tag_allocnet/9p/client.c:278[inline]p9_client_prepare_req+0x20a/0x1770net/9p/client.c:641p9_client_rpc+0x27e/0x1340net/9p/client.c:688p9_client_create+0x1551/0x1ff0net/9p/client.c:1031v9fs_session_init+0x1b9/0x28e0fs/9p/v9fs.c:410v9fs_mount+0xe2/0x12b0fs/9p/vfs_super.c:122legacy_get_tree+0x114/0x290fs/fs_context.c:662vfs_get_tree+0xa7/0x570fs/super.c:1797do_new_mount+0x71f/0x15e0fs/namespace.c:3352path_mount+0x742/0x1f20fs/namespace.c:3679do_mountfs/namespace.c:3692[inline]__do_sys_mountfs/namespace.c:3898[inline]__se_sys_mount+0x725/0x810fs/namespace.c:3875__x64_sys_mount+0xe4/0x150fs/namespace.c:3875do_syscall_64+0xd5/0x1f0entry_SYSCALL_64_after_hwframe+0x6d/0x75
If p9_check_errors() fails early in p9_client_rpc(), req->rc.tag
will not be properly initialized. However, trace_9p_client_res()
ends up trying to print it out anyway before p9_client_rpc()
finishes.
Fix this issue by assigning default values to p9_fcall fields
such as 'tag' and (just in case KMSAN unearths something new) 'id'
during the tag allocation stage.