mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lizhi Xu <lizhi.xu@windriver.com>
To: <lizhi.xu@windriver.com>
Cc: <arnd@arndb.de>, <bcm-kernel-feedback-list@broadcom.com>,
	<bryan-bt.tan@broadcom.com>, <gregkh@linuxfoundation.org>,
	<linux-kernel@vger.kernel.org>, <syzkaller-bugs@googlegroups.com>,
	<vishnu.dasa@broadcom.com>, <sfr@canb.auug.org.au>
Subject: [PATCH V2] vmci: Prevent the dispatching of uninitialized payloads
Date: Thu, 3 Jul 2025 15:53:34 +0800	[thread overview]
Message-ID: <20250703075334.856445-1-lizhi.xu@windriver.com> (raw)
In-Reply-To: <20250627055214.2967129-1-lizhi.xu@windriver.com>

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.

Fixes: 28d6692cd8fb ("VMCI: context implementation.")
Reported-by: syzbot+9b9124ae9b12d5af5d95@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=9b9124ae9b12d5af5d95
Tested-by: syzbot+9b9124ae9b12d5af5d95@syzkaller.appspotmail.com
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
---
V1 -> V2: fix building warning reported by Stephen Rothwell

 drivers/misc/vmw_vmci/vmci_context.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/vmci_context.c
index f22b44827e92..d566103caa27 100644
--- a/drivers/misc/vmw_vmci/vmci_context.c
+++ b/drivers/misc/vmw_vmci/vmci_context.c
@@ -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;
 
-- 
2.43.0


  reply	other threads:[~2025-07-03  7:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-19 23:57 [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3) syzbot
2025-06-20  1:03 ` [syzbot] " syzbot
2025-06-20  4:21 ` syzbot
2025-06-20  5:23 ` syzbot
2025-06-20  6:52 ` syzbot
2025-06-20  6:54 ` syzbot
2025-06-22  2:37 ` Edward Adam Davis
2025-06-22  3:02   ` syzbot
2025-06-22  4:46 ` Hillf Danton
2025-06-22  5:19   ` syzbot
2025-06-22  6:28 ` Hillf Danton
2025-06-22  7:32   ` syzbot
2025-06-23  3:03 ` [syzbot] " syzbot
2025-06-23  8:03 ` syzbot
2025-06-23  8:50 ` syzbot
2025-06-23  9:45 ` syzbot
2025-06-23 12:29 ` Edward Adam Davis
2025-06-23 13:45   ` syzbot
2025-06-26  2:17 ` [syzbot] " syzbot
2025-06-26  2:49 ` syzbot
2025-06-27  3:26 ` syzbot
2025-06-27  5:13 ` syzbot
2025-06-27  5:52 ` [PATCH] vmci: Prevent the dispatching of uninitialized payloads Lizhi Xu
2025-07-03  7:53   ` Lizhi Xu [this message]
2025-07-03  8:09 ` [syzbot] Re: [syzbot] [kernel?] KMSAN: kernel-infoleak in vmci_host_unlocked_ioctl (3) syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250703075334.856445-1-lizhi.xu@windriver.com \
    --to=lizhi.xu@windriver.com \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bryan-bt.tan@broadcom.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=vishnu.dasa@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®