KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Subsystems (2)
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 08215f5486ec Merge tag 'kbuild-fixes-v6.16' of git://git.k.. git tree: upstream console+strace: https://syzkaller.appspot.com/x/log.txt?x=13f7fd70580000 kernel config: https://syzkaller.appspot.com/x/.config?x=61539536677af51c dashboard link: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95 compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17f7fd70580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1485690c580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/01c395d764eb/disk-08215f54.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/15fc58e6441d/vmlinux-08215f54.xz
kernel image: https://storage.googleapis.com/syzbot-assets/dbd5ac78ef83/bzImage-08215f54.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
=====================================================
BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline] BUG: KMSAN: kernel-infoleak in _inline_copy_to_user include/linux/uaccess.h:196 [inline] BUG: KMSAN: kernel-infoleak in _copy_to_user+0xcc/0x120 lib/usercopy.c:26 instrument_copy_to_user include/linux/instrumented.h:114 [inline] _inline_copy_to_user include/linux/uaccess.h:196 [inline] _copy_to_user+0xcc/0x120 lib/usercopy.c:26 copy_to_user include/linux/uaccess.h:225 [inline] vmci_host_do_receive_datagram drivers/misc/vmw_vmci/vmci_host.c:438 [inline] vmci_host_unlocked_ioctl+0x1e7e/0x5200 drivers/misc/vmw_vmci/vmci_host.c:932 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0x23c/0x400 fs/ioctl.c:893 __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:893 x64_sys_call+0x1ebe/0x3db0 arch/x86/include/generated/asm/syscalls_64.h:17 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable __x.i.i created at:
set_xfeature_in_sigframe arch/x86/kernel/fpu/xstate.h:81 [inline] save_xstate_epilog arch/x86/kernel/fpu/signal.c:140 [inline] copy_fpstate_to_sigframe+0x11f2/0x13d0 arch/x86/kernel/fpu/signal.c:232 get_sigframe+0xc6a/0x1020 arch/x86/kernel/signal.c:163
Bytes 28-31 of 40 are uninitialized
Memory access of size 40 starts at ffff888131f74080 Data copied to user address 000000000000a4bf
CPU: 1 UID: 0 PID: 5798 Comm: syz-executor419 Not tainted 6.16.0-rc1-syzkaller-00239-g08215f5486ec #0 PREEMPT(undef) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 =====================================================
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_context.c +1 -1
@@ -314,7 +314,7 @@ int vmci_ctx_enqueue_datagram(u32 cid, struct vmci_datagram *dg) }/* Allocate guest call entry and add it to the target VM's queue. */ - dq_entry =kmalloc (sizeof (*dq_entry),GFP_KERNEL ); + dq_entry =kzalloc (sizeof (*dq_entry),GFP_KERNEL );if (dq_entry ==NULL ) {pr_warn ("Failed to allocate memory for datagram\n" );vmci_ctx_put (context);
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +9 -3
@@ -385,14 +385,20 @@ static int vmci_host_do_send_datagram(struct vmci_host_dev *vmci_host_dev,return -EINVAL ; } - dg =memdup_user ((void __user *)(uintptr_t )send_info.addr, - send_info.len); -if (IS_ERR (dg)) { + dg =kzalloc (send_info.len,GFP_KERNEL ); + +if (IS_ERR_OR_NULL (dg)) {vmci_ioctl_err ("cannot allocate memory to dispatch datagram\n" );return PTR_ERR (dg); } +if (copy_from_user (dg, send_info.addr, send_info.len)) { +vmci_ioctl_err ("copy datagram fails\n" ); +kfree (dg); +return -EFAULT ; + } +if (VMCI_DG_SIZE (dg) != send_info.len) {vmci_ioctl_err ("datagram size mismatch\n" );kfree (dg);
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +9 -3
@@ -385,14 +385,20 @@ static int vmci_host_do_send_datagram(struct vmci_host_dev *vmci_host_dev,return -EINVAL ; } - dg =memdup_user ((void __user *)(uintptr_t )send_info.addr, - send_info.len); -if (IS_ERR (dg)) { + dg =kzalloc (send_info.len,GFP_KERNEL ); + +if (IS_ERR_OR_NULL (dg)) {vmci_ioctl_err ("cannot allocate memory to dispatch datagram\n" );return PTR_ERR (dg); } +if (copy_from_user (dg, (void __user *)(uintptr_t )send_info.addr, send_info.len)) { +vmci_ioctl_err ("copy datagram fails\n" ); +kfree (dg); +return -EFAULT ; + } +if (VMCI_DG_SIZE (dg) != send_info.len) {vmci_ioctl_err ("datagram size mismatch\n" );kfree (dg);
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +1 -0
@@ -398,6 +398,7 @@ static int vmci_host_do_send_datagram(struct vmci_host_dev *vmci_host_dev,kfree (dg);return -EINVAL ; } +memset (dg +27 ,0 ,4 ); pr_devel("Datagram dst (handle=0x%x:0x%x) src (handle=0x%x:0x%x), payload (size=%llu bytes)\n", dg->dst.context, dg->dst.resource,
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +1 -0
@@ -398,6 +398,7 @@ static int vmci_host_do_send_datagram(struct vmci_host_dev *vmci_host_dev,kfree (dg);return -EINVAL ; } +memset ((char *)dg +27 ,0 ,4 ); pr_devel("Datagram dst (handle=0x%x:0x%x) src (handle=0x%x:0x%x), payload (size=%llu bytes)\n", dg->dst.context, dg->dst.resource,
#syz test
drivers/misc/vmw_vmci/vmci_host.c +1 -0
@@ -434,6 +434,7 @@ static int vmci_host_do_receive_datagram(struct vmci_host_dev *vmci_host_dev, &size, &dg);if (recv_info.result >=VMCI_SUCCESS ) { +memset ((char *)dg +27 ,0 ,4 );void __user *ubuf = (void __user *)(uintptr_t )recv_info.addr; retval =copy_to_user (ubuf, dg,VMCI_DG_SIZE (dg));kfree (dg);
syzbot
syzbotsyzbot has tested the proposed patch but the reproducer is still triggering an issue: KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl
=====================================================
BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline] BUG: KMSAN: kernel-infoleak in _inline_copy_to_user include/linux/uaccess.h:196 [inline] BUG: KMSAN: kernel-infoleak in _copy_to_user+0xcc/0x120 lib/usercopy.c:26 instrument_copy_to_user include/linux/instrumented.h:114 [inline] _inline_copy_to_user include/linux/uaccess.h:196 [inline] _copy_to_user+0xcc/0x120 lib/usercopy.c:26 copy_to_user include/linux/uaccess.h:225 [inline] vmci_host_do_receive_datagram drivers/misc/vmw_vmci/vmci_host.c:439 [inline] vmci_host_unlocked_ioctl+0x1ead/0x5240 drivers/misc/vmw_vmci/vmci_host.c:933 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0x239/0x400 fs/ioctl.c:893 __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:893 x64_sys_call+0x1ebe/0x3db0 arch/x86/include/generated/asm/syscalls_64.h:17 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
kmemdup_noprof+0xb0/0x100 mm/util.c:139 kmemdup_noprof include/linux/fortify-string.h:765 [inline] dg_dispatch_as_host drivers/misc/vmw_vmci/vmci_datagram.c:272 [inline] vmci_datagram_dispatch+0x4eb/0x1560 drivers/misc/vmw_vmci/vmci_datagram.c:340 ctx_fire_notification drivers/misc/vmw_vmci/vmci_context.c:257 [inline] ctx_free_ctx drivers/misc/vmw_vmci/vmci_context.c:435 [inline] kref_put include/linux/kref.h:65 [inline] vmci_ctx_put+0x88e/0x15d0 drivers/misc/vmw_vmci/vmci_context.c:497 vmci_ctx_destroy+0x15d/0x250 drivers/misc/vmw_vmci/vmci_context.c:195 vmci_host_do_init_context drivers/misc/vmw_vmci/vmci_host.c:341 [inline] vmci_host_unlocked_ioctl+0x45cd/0x5240 drivers/misc/vmw_vmci/vmci_host.c:929 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0x239/0x400 fs/ioctl.c:893 __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:893 x64_sys_call+0x1ebe/0x3db0 arch/x86/include/generated/asm/syscalls_64.h:17 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable ev.i.i created at:
ctx_fire_notification drivers/misc/vmw_vmci/vmci_context.c:248 [inline] ctx_free_ctx drivers/misc/vmw_vmci/vmci_context.c:435 [inline] kref_put include/linux/kref.h:65 [inline] vmci_ctx_put+0x76b/0x15d0 drivers/misc/vmw_vmci/vmci_context.c:497 vmci_ctx_destroy+0x15d/0x250 drivers/misc/vmw_vmci/vmci_context.c:195
Byte 31 of 40 is uninitialized
Memory access of size 40 starts at ffff8880219a0880 Data copied to user address 000000000000a4bf
CPU: 0 UID: 0 PID: 6814 Comm: syz.0.16 Not tainted 6.16.0-rc2-syzkaller-00318-g739a6c93cc75-dirty #0 PREEMPT(undef) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 =====================================================
Tested on:
commit: 739a6c93 Merge tag 'nfsd-6.16-1' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=12580ebc580000 kernel config: https://syzkaller.appspot.com/x/.config?x=db26f33438d76de9 dashboard link: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95 compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6 patch: https://syzkaller.appspot.com/x/patch.diff?x=16fdf30c580000
On Thu, 19 Jun 2025 16:57:26 -0700
Quoted 10 lines
syzbot found the following issue on:
HEAD commit: 08215f5486ec Merge tag 'kbuild-fixes-v6.16' of git://git.k.. git tree: upstream console+strace: https://syzkaller.appspot.com/x/log.txt?x=13f7fd70580000 kernel config: https://syzkaller.appspot.com/x/.config?x=61539536677af51c dashboard link: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95 compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17f7fd70580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1485690c580000
#syz test
drivers/misc/vmw_vmci/vmci_context.c +1 -0
@@ -535,6 +535,7 @@ int vmci_ctx_dequeue_datagram(struct vmc (u32) *max_size);return VMCI_ERROR_NO_MEM ; } + *max_size = dq_entry->dg_size;list_del (list_item); context->pending_datagrams--;
drivers/misc/vmw_vmci/vmci_host.c +1 -1
@@ -435,7 +435,7 @@ static int vmci_host_do_receive_datagramif (recv_info.result >=VMCI_SUCCESS ) {void __user *ubuf = (void __user *)(uintptr_t )recv_info.addr; - retval =copy_to_user (ubuf, dg,VMCI_DG_SIZE (dg)); + retval =copy_to_user (ubuf, dg, size);kfree (dg);if (retval !=0 )return -EFAULT ;
--
syzbot
syzbotsyzbot has tested the proposed patch but the reproducer is still triggering an issue: KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl
=====================================================
BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline] BUG: KMSAN: kernel-infoleak in _inline_copy_to_user include/linux/uaccess.h:196 [inline] BUG: KMSAN: kernel-infoleak in _copy_to_user+0xcc/0x120 lib/usercopy.c:26 instrument_copy_to_user include/linux/instrumented.h:114 [inline] _inline_copy_to_user include/linux/uaccess.h:196 [inline] _copy_to_user+0xcc/0x120 lib/usercopy.c:26 copy_to_user include/linux/uaccess.h:225 [inline] vmci_host_do_receive_datagram drivers/misc/vmw_vmci/vmci_host.c:438 [inline] vmci_host_unlocked_ioctl+0x1e74/0x51f0 drivers/misc/vmw_vmci/vmci_host.c:932 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0x239/0x400 fs/ioctl.c:893 __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:893 x64_sys_call+0x1ebe/0x3db0 arch/x86/include/generated/asm/syscalls_64.h:17 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
kmemdup_noprof+0xb0/0x100 mm/util.c:139 kmemdup_noprof include/linux/fortify-string.h:765 [inline] dg_dispatch_as_host drivers/misc/vmw_vmci/vmci_datagram.c:272 [inline] vmci_datagram_dispatch+0x4eb/0x1560 drivers/misc/vmw_vmci/vmci_datagram.c:340 ctx_fire_notification drivers/misc/vmw_vmci/vmci_context.c:257 [inline] ctx_free_ctx drivers/misc/vmw_vmci/vmci_context.c:435 [inline] kref_put include/linux/kref.h:65 [inline] vmci_ctx_put+0x88e/0x15d0 drivers/misc/vmw_vmci/vmci_context.c:497 vmci_ctx_destroy+0x15d/0x250 drivers/misc/vmw_vmci/vmci_context.c:195 vmci_host_do_init_context drivers/misc/vmw_vmci/vmci_host.c:341 [inline] vmci_host_unlocked_ioctl+0x4579/0x51f0 drivers/misc/vmw_vmci/vmci_host.c:928 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl+0x239/0x400 fs/ioctl.c:893 __x64_sys_ioctl+0x97/0xe0 fs/ioctl.c:893 x64_sys_call+0x1ebe/0x3db0 arch/x86/include/generated/asm/syscalls_64.h:17 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd9/0x210 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable ev.i.i created at:
ctx_fire_notification drivers/misc/vmw_vmci/vmci_context.c:248 [inline] ctx_free_ctx drivers/misc/vmw_vmci/vmci_context.c:435 [inline] kref_put include/linux/kref.h:65 [inline] vmci_ctx_put+0x76b/0x15d0 drivers/misc/vmw_vmci/vmci_context.c:497 vmci_ctx_destroy+0x15d/0x250 drivers/misc/vmw_vmci/vmci_context.c:195
Bytes 28-31 of 40 are uninitialized
Memory access of size 40 starts at ffff8880470d5780 Data copied to user address 000000000000a4bf
CPU: 1 UID: 0 PID: 6789 Comm: syz.0.16 Not tainted 6.16.0-rc2-syzkaller-00318-g739a6c93cc75-dirty #0 PREEMPT(undef) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 =====================================================
Tested on:
commit: 739a6c93 Merge tag 'nfsd-6.16-1' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=1392b30c580000 kernel config: https://syzkaller.appspot.com/x/.config?x=db26f33438d76de9 dashboard link: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95 compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6 patch: https://syzkaller.appspot.com/x/patch.diff?x=167c2182580000
On Thu, 19 Jun 2025 16:57:26 -0700
Quoted 10 lines
syzbot found the following issue on:
HEAD commit: 08215f5486ec Merge tag 'kbuild-fixes-v6.16' of git://git.k.. git tree: upstream console+strace: https://syzkaller.appspot.com/x/log.txt?x=13f7fd70580000 kernel config: https://syzkaller.appspot.com/x/.config?x=61539536677af51c dashboard link: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95 compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17f7fd70580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1485690c580000
#syz test
drivers/misc/vmw_vmci/vmci_context.c +1 -1
@@ -245,7 +245,7 @@ static int ctx_fire_notification(u32 con array_size =vmci_handle_arr_get_size (subscriber_array);for (i =0 ; i < array_size; i++) {int result; -struct vmci_event_ctx ev; +struct vmci_event_ctx ev = {0 }; ev.msg.hdr.dst =vmci_handle_arr_get_entry (subscriber_array, i); ev.msg.hdr.src = vmci_make_handle(VMCI_HYPERVISOR_CONTEXT_ID,
--
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: 739a6c93 Merge tag 'nfsd-6.16-1' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=10762182580000 kernel config: https://syzkaller.appspot.com/x/.config?x=db26f33438d76de9 dashboard link: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95 compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6 patch: https://syzkaller.appspot.com/x/patch.diff?x=1756b30c580000
Note: testing is done by a robot and is best-effort only.
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +3 -0
@@ -433,6 +433,9 @@ static int vmci_host_do_receive_datagram(struct vmci_host_dev *vmci_host_dev, recv_info.result =vmci_ctx_dequeue_datagram (vmci_host_dev->context, &size, &dg); +if (!vmci_host_code_active ()) +return VMCI_ERROR_UNAVAILABLE ; +if (recv_info.result >=VMCI_SUCCESS ) {void __user *ubuf = (void __user *)(uintptr_t )recv_info.addr; retval =copy_to_user (ubuf, dg,VMCI_DG_SIZE (dg));
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_context.c +1 -1
@@ -245,7 +245,7 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) array_size =vmci_handle_arr_get_size (subscriber_array);for (i =0 ; i < array_size; i++) {int result; -struct vmci_event_ctx ev; +struct vmci_event_ctx ev = {0 }; ev.msg.hdr.dst =vmci_handle_arr_get_entry (subscriber_array, i); ev.msg.hdr.src = vmci_make_handle(VMCI_HYPERVISOR_CONTEXT_ID,
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +15 -5
@@ -426,8 +426,12 @@ static int vmci_host_do_receive_datagram(struct vmci_host_dev *vmci_host_dev,return -EINVAL ; } -if (copy_from_user (&recv_info, uptr,sizeof (recv_info))) -return -EFAULT ; +mutex_lock (&vmci_host_dev->lock); + +if (copy_from_user (&recv_info, uptr,sizeof (recv_info))) { + retval = -EFAULT ; + goto out; + } size = recv_info.len; recv_info.result = vmci_ctx_dequeue_datagram(vmci_host_dev->context,
@@ -437,11 +441,17 @@ static int vmci_host_do_receive_datagram(struct vmci_host_dev *vmci_host_dev,void __user *ubuf = (void __user *)(uintptr_t )recv_info.addr; retval =copy_to_user (ubuf, dg,VMCI_DG_SIZE (dg));kfree (dg); -if (retval !=0 ) -return -EFAULT ; +if (retval !=0 ) { + retval = -EFAULT ; + goto out; + } } -return copy_to_user (uptr, &recv_info,sizeof (recv_info)) ? -EFAULT :0 ; + retval =copy_to_user (uptr, &recv_info,sizeof (recv_info)) ? -EFAULT :0 ; + +out: +mutex_unlock (&vmci_host_dev->lock); +return retval; } static int vmci_host_do_alloc_queuepair(struct vmci_host_dev *vmci_host_dev,
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +18 -5
@@ -293,6 +293,8 @@ static int vmci_host_get_version(struct vmci_host_dev *vmci_host_dev,#define vmci_ioctl_err (fmt, ...) \ pr_devel("%s: " fmt, ioctl_name, ##__VA_ARGS__) +static DEFINE_MUTEX (init_rec_mutex); +static int vmci_host_do_init_context (struct vmci_host_dev *vmci_host_dev,const char *ioctl_name,void __user *uptr)
@@ -306,6 +308,7 @@ static int vmci_host_do_init_context(struct vmci_host_dev *vmci_host_dev,return -EFAULT ; } +mutex_lock (&init_rec_mutex);mutex_lock (&vmci_host_dev->lock);if (vmci_host_dev->ct_type !=VMCIOBJ_NOT_SET ) {
@@ -354,6 +357,7 @@ static int vmci_host_do_init_context(struct vmci_host_dev *vmci_host_dev, out:mutex_unlock (&vmci_host_dev->lock); +mutex_unlock (&init_rec_mutex);return retval; }
@@ -426,8 +430,11 @@ static int vmci_host_do_receive_datagram(struct vmci_host_dev *vmci_host_dev,return -EINVAL ; } -if (copy_from_user (&recv_info, uptr,sizeof (recv_info))) -return -EFAULT ; +mutex_lock (&init_rec_mutex); +if (copy_from_user (&recv_info, uptr,sizeof (recv_info))) { + retval = -EFAULT ; + goto out; + } size = recv_info.len; recv_info.result = vmci_ctx_dequeue_datagram(vmci_host_dev->context,
@@ -437,11 +444,17 @@ static int vmci_host_do_receive_datagram(struct vmci_host_dev *vmci_host_dev,void __user *ubuf = (void __user *)(uintptr_t )recv_info.addr; retval =copy_to_user (ubuf, dg,VMCI_DG_SIZE (dg));kfree (dg); -if (retval !=0 ) -return -EFAULT ; +if (retval !=0 ) { + retval = -EFAULT ; + goto out; + } } -return copy_to_user (uptr, &recv_info,sizeof (recv_info)) ? -EFAULT :0 ; + retval =copy_to_user (uptr, &recv_info,sizeof (recv_info)) ? -EFAULT :0 ; + +out: +mutex_unlock (&init_rec_mutex); +return retval; } static int vmci_host_do_alloc_queuepair(struct vmci_host_dev *vmci_host_dev,
#syz test
drivers/misc/vmw_vmci/vmci_host.c +9 -2
@@ -293,6 +293,8 @@ static int vmci_host_get_version(struct vmci_host_dev *vmci_host_dev,#define vmci_ioctl_err (fmt, ...) \ pr_devel("%s: " fmt, ioctl_name, ##__VA_ARGS__) +static DEFINE_MUTEX (init_rec_mutex); +static int vmci_host_do_init_context (struct vmci_host_dev *vmci_host_dev,const char *ioctl_name,void __user *uptr)
@@ -922,7 +924,9 @@ static long vmci_host_unlocked_ioctl(struct file *filp,struct vmci_host_dev *vmci_host_dev = filp->private_data;void __user *uptr = (void __user *)ioarg; +int ret =0 ; +mutex_lock (&init_rec_mutex);switch (iocmd) {case IOCTL_VMCI_INIT_CONTEXT :VMCI_DO_IOCTL (INIT_CONTEXT , init_context);
@@ -957,13 +961,16 @@ static long vmci_host_unlocked_ioctl(struct file *filp,case IOCTL_VMCI_VERSION :case IOCTL_VMCI_VERSION2 : -return vmci_host_get_version (vmci_host_dev, iocmd, uptr); + ret =vmci_host_get_version (vmci_host_dev, iocmd, uptr);default :pr_devel ("%s: Unknown ioctl (iocmd=%d)\n" , __func__, iocmd); -return -EINVAL ; + ret -EINVAL ; } +mutex_unlock (&init_rec_mutex); +return ret; +#undef VMCI_DO_IOCTL }
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Tested on:
commit: 86731a2a Linux 6.16-rc3 git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=12553b0c580000 kernel config: https://syzkaller.appspot.com/x/.config?x=595d344ff0b23ac5 dashboard link: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95 compiler: Debian clang version 20.1.6 (++20250514063057+1e4d39e07757-1~exp1~20250514183223.118), Debian LLD 20.1.6 patch: https://syzkaller.appspot.com/x/patch.diff?x=106e3b0c580000
Note: testing is done by a robot and is best-effort only.
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +6 -1
@@ -91,7 +91,7 @@ struct vmci_host_dev {static struct vmci_ctx *host_context;static bool vmci_host_device_initialized;static atomic_t vmci_host_active_users =ATOMIC_INIT (0 ); - +static atomic_t vmci_host_dev_open =ATOMIC_INIT (0 );/* * Determines whether the VMCI host personality is * available. Since the core functionality of the host driver is
@@ -120,6 +120,11 @@ static int vmci_host_open(struct inode *inode, struct file *filp) {struct vmci_host_dev *vmci_host_dev; +if (atomic_inc_return (&vmci_host_dev_open) >1 ) { +atomic_dec (&vmci_host_dev_open); +return -EBUSY ; + } + vmci_host_dev =kzalloc (sizeof (struct vmci_host_dev ),GFP_KERNEL );if (vmci_host_dev ==NULL )return -ENOMEM ;
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_host.c +7 -1
@@ -91,7 +91,7 @@ struct vmci_host_dev {static struct vmci_ctx *host_context;static bool vmci_host_device_initialized;static atomic_t vmci_host_active_users =ATOMIC_INIT (0 ); - +static atomic_t vmci_host_dev_open =ATOMIC_INIT (0 );/* * Determines whether the VMCI host personality is * available. Since the core functionality of the host driver is
@@ -120,6 +120,11 @@ static int vmci_host_open(struct inode *inode, struct file *filp) {struct vmci_host_dev *vmci_host_dev; +if (atomic_inc_return (&vmci_host_dev_open) >1 ) { +atomic_dec (&vmci_host_dev_open); +return -EBUSY ; + } + vmci_host_dev =kzalloc (sizeof (struct vmci_host_dev ),GFP_KERNEL );if (vmci_host_dev ==NULL )return -ENOMEM ;
@@ -155,6 +160,7 @@ static int vmci_host_close(struct inode *inode, struct file *filp)kfree (vmci_host_dev); filp->private_data =NULL ; +atomic_dec (&vmci_host_dev_open);return 0 ; }
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_context.c +1 -0
@@ -251,6 +251,7 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID ); ev.msg.hdr.payload_size =sizeof (ev) -sizeof (ev.msg.hdr); +memset (&ev.msg.hdr +sizeof (ev.msg.hdr),0 , ev.msg.hdr.payload_size); ev.msg.event_data.event =VMCI_EVENT_CTX_REMOVED ; ev.payload.context_id = context_id;
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_context.c +1 -0
@@ -251,6 +251,7 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID ); ev.msg.hdr.payload_size =sizeof (ev) -sizeof (ev.msg.hdr); +memset ((char *)&ev.msg.hdr +sizeof (ev.msg.hdr),0 , ev.msg.hdr.payload_size); ev.msg.event_data.event =VMCI_EVENT_CTX_REMOVED ; ev.payload.context_id = context_id;
PATCH 1/1 vmci: Prevent the dispatching of uninitialized payloads
In reply to syzbotThe reproducer executes the host's unlocked_ioctl call in two different tasks. When init_context fails, the struct vmci_event_ctx is not fully initialized when executing vmci_datagram_dispatch() to send events to all vm contexts. This affects the datagram taken from the datagram queue of its context by another task, because the datagram payload is not initialized according to the size payload_size, which causes the kernel data to leak to the user space.
Before dispatching the datagram, and before setting the payload content, explicitly set the payload content to 0 to avoid data leakage caused by incomplete payload initialization.
--- drivers/misc/vmw_vmci/vmci_context.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/vmw_vmci/vmci_context.c +2 -0
@@ -251,6 +251,8 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID ); ev.msg.hdr.payload_size =sizeof (ev) -sizeof (ev.msg.hdr); +memset ((char *)&ev.msg.hdr +sizeof (ev.msg.hdr),0 , + ev.msg.hdr.payload_size); ev.msg.event_data.event =VMCI_EVENT_CTX_REMOVED ; ev.payload.context_id = context_id;
Signature · 1 line
2.43.0
PATCH v2 1/1 vmci: Prevent the dispatching of uninitialized payloads
The reproducer executes the host's unlocked_ioctl call in two different tasks. When init_context fails, the struct vmci_event_ctx is not fully initialized when executing vmci_datagram_dispatch() to send events to all vm contexts. This affects the datagram taken from the datagram queue of its context by another task, because the datagram payload is not initialized according to the size payload_size, which causes the kernel data to leak to the user space.
Before dispatching the datagram, and before setting the payload content, explicitly set the payload content to 0 to avoid data leakage caused by incomplete payload initialization.
To avoid the oob check failure when executing __compiletime_lessthan() in memset(), directly use the address of the vmci_event_ctx instance ev to replace ev.msg.hdr, because their addresses are the same.
---
V1 -> V2: fix building warning reported by Stephen Rothwell
drivers/misc/vmw_vmci/vmci_context.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/vmw_vmci/vmci_context.c +2 -0
@@ -251,6 +251,8 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID ); ev.msg.hdr.payload_size =sizeof (ev) -sizeof (ev.msg.hdr); +memset ((char *)&ev +sizeof (ev.msg.hdr),0 , + ev.msg.hdr.payload_size); ev.msg.event_data.event =VMCI_EVENT_CTX_REMOVED ; ev.payload.context_id = context_id;
Signature · 1 line
2.43.0
syzbot
syzbotFor archival purposes, forwarding an incoming command email to [email protected].
For archival purposes, forwarding an incoming command email to [email protected].
***
Subject: Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3)
Author: [email protected]
#syz test
drivers/misc/vmw_vmci/vmci_context.c +1 -0
@@ -251,6 +251,7 @@ static int ctx_fire_notification(u32 context_id, u32 priv_flags) ev.msg.hdr.src =vmci_make_handle (VMCI_HYPERVISOR_CONTEXT_ID ,VMCI_CONTEXT_RESOURCE_ID ); ev.msg.hdr.payload_size =sizeof (ev) -sizeof (ev.msg.hdr); +memset ((char *)&ev +sizeof (ev.msg.hdr),0 , ev.msg.hdr.payload_size); ev.msg.event_data.event =VMCI_EVENT_CTX_REMOVED ; ev.payload.context_id = context_id;