linux-um archives
 help / color / mirror / Atom feed
From: Michael Bommarito <michael.bommarito@gmail.com>
To: Richard Weinberger <richard@nod.at>,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	Johannes Berg <johannes@sipsolutions.net>
Cc: Kees Cook <kees@kernel.org>, Tiwei Bie <tiwei.btw@antgroup.com>,
	linux-um@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] um: virtio_uml: fix heap overflow in vhost_user_get_config()
Date: Mon, 22 Jun 2026 08:47:50 -0400	[thread overview]
Message-ID: <20260622124750.1694957-1-michael.bommarito@gmail.com> (raw)

vhost_user_get_config() sizes its reply buffer from header + payload:

	size_t payload_size = sizeof(msg->payload.config) + cfg_size;
	size_t msg_size = sizeof(msg->header) + payload_size;
	...
	msg = kzalloc(msg_size, GFP_KERNEL);

but then receives the response with msg_size as the payload cap:

	rc = vhost_user_recv_resp(vu_dev, msg, msg_size);

vhost_user_recv() reads the header, then full_read()s header.size bytes
into &msg->payload after checking only "size > max_payload_size". The
payload area is msg_size - sizeof(msg->header) == payload_size bytes, so
passing msg_size as the cap lets a peer set header.size up to msg_size
and write sizeof(struct vhost_user_msg_header) (12) bytes past the end
of the kzalloc(msg_size) buffer -- a slab out-of-bounds write of
peer-controlled content.

Pass payload_size, which is the size the payload area was allocated for.

A malicious or compromised vhost-user backend triggers this during
device probe (vu_get -> vhost_user_get_config) with no guest action,
which matters in the confidential-computing model where the guest does
not trust the device backend.

Fixes: 5d38f324993f ("um: drivers: Add virtio vhost-user driver")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
---
Reproduced on a UML KASAN build (ARCH=um, CONFIG_KASAN=y) off this base.
A stub vhost-user backend that answers GET_CONFIG with header.size set to
the full msg_size makes vhost_user_recv() full_read() 12 bytes past the
kzalloc'd reply buffer; KASAN reports a slab-out-of-bounds write in
vhost_user_get_config(). With this patch the oversized reply is rejected
(-EPROTO) and KASAN is clean. Benign control: a correctly-sized GET_CONFIG
reply succeeds on both stock and patched. Before/after logs available on
request.

 arch/um/drivers/virtio_uml.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c
index 7425a8548141a..38e960bec9e65 100644
--- a/arch/um/drivers/virtio_uml.c
+++ b/arch/um/drivers/virtio_uml.c
@@ -568,7 +568,7 @@ static void vhost_user_get_config(struct virtio_uml_device *vu_dev,
 		goto free;
 	}
 
-	rc = vhost_user_recv_resp(vu_dev, msg, msg_size);
+	rc = vhost_user_recv_resp(vu_dev, msg, payload_size);
 	if (rc) {
 		vu_err(vu_dev,
 		       "receiving VHOST_USER_GET_CONFIG response failed: %d\n",

base-commit: ef0c9f75a19532d7675384708fc8621e10850104
-- 
2.53.0



             reply	other threads:[~2026-06-22 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 12:47 Michael Bommarito [this message]
2026-07-22 21:20 ` [PATCH] um: virtio_uml: fix heap overflow in vhost_user_get_config() Richard Weinberger

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=20260622124750.1694957-1-michael.bommarito@gmail.com \
    --to=michael.bommarito@gmail.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=johannes@sipsolutions.net \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=tiwei.btw@antgroup.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