In the Linux kernel, the following vulnerability has been resolved:
can: bcm: bcm_tx_setup(): fix KMSAN uninit-value in vfs_write
Syzkaller reported the following issue:
=====================================================BUG: KMSAN: uninit-value in aio_rw_done fs/aio.c:1520[inline]BUG: KMSAN: uninit-value in aio_write+0x899/0x950fs/aio.c:1600aio_rw_donefs/aio.c:1520[inline]aio_write+0x899/0x950fs/aio.c:1600io_submit_one+0x1d1c/0x3bf0fs/aio.c:2019__do_sys_io_submitfs/aio.c:2078[inline]__se_sys_io_submit+0x293/0x770fs/aio.c:2048__x64_sys_io_submit+0x92/0xd0fs/aio.c:2048do_syscall_x64arch/x86/entry/common.c:50[inline]do_syscall_64+0x3d/0xb0arch/x86/entry/common.c:80entry_SYSCALL_64_after_hwframe+0x63/0xcdUninit was created at:slab_post_alloc_hookmm/slab.h:766[inline]slab_alloc_nodemm/slub.c:3452[inline]__kmem_cache_alloc_node+0x71f/0xce0mm/slub.c:3491__do_kmalloc_nodemm/slab_common.c:967[inline]__kmalloc+0x11d/0x3b0mm/slab_common.c:981kmalloc_arrayinclude/linux/slab.h:636[inline]bcm_tx_setup+0x80e/0x29d0net/can/bcm.c:930bcm_sendmsg+0x3a2/0xce0net/can/bcm.c:1351sock_sendmsg_nosecnet/socket.c:714[inline]sock_sendmsgnet/socket.c:734[inline]sock_write_iter+0x495/0x5e0net/socket.c:1108call_write_iterinclude/linux/fs.h:2189[inline]aio_write+0x63a/0x950fs/aio.c:1600io_submit_one+0x1d1c/0x3bf0fs/aio.c:2019__do_sys_io_submitfs/aio.c:2078[inline]__se_sys_io_submit+0x293/0x770fs/aio.c:2048__x64_sys_io_submit+0x92/0xd0fs/aio.c:2048do_syscall_x64arch/x86/entry/common.c:50[inline]do_syscall_64+0x3d/0xb0arch/x86/entry/common.c:80entry_SYSCALL_64_after_hwframe+0x63/0xcdCPU: 1 PID: 5034 Comm: syz-executor350 Not tainted 6.2.0-rc6-syzkaller-80422-geda666ff2276 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
=====================================================
We can follow the call chain and find that 'bcm_tx_setup' function
calls 'memcpy_from_msg' to copy some content to the newly allocated
frame of 'op->frames'. After that the 'len' field of copied structure
being compared with some constant value (64 or 8). However, if
'memcpy_from_msg' returns an error, we will compare some uninitialized
memory. This triggers 'uninit-value' issue.
This patch will add 'memcpy_from_msg' possible errors processing to
avoid uninit-value issue.