9d3ce7cd74
- kvm-ui-clipboard-mark-type-as-not-available-when-there-i.patch [RHEL-19629] - kvm-ui-clipboard-add-asserts-for-update-and-request.patch [RHEL-19629] - kvm-hw-i386-pc-Defer-smbios_set_defaults-to-machine_done.patch [RHEL-21705] - kvm-Implement-base-of-SMBIOS-type-9-descriptor.patch [RHEL-21705] - kvm-Implement-SMBIOS-type-9-v2.6.patch [RHEL-21705] - kvm-smbios-cleanup-smbios_get_tables-from-legacy-handlin.patch [RHEL-21705] - kvm-smbios-get-rid-of-smbios_smp_sockets-global.patch [RHEL-21705] - kvm-smbios-get-rid-of-smbios_legacy-global.patch [RHEL-21705] - kvm-smbios-avoid-mangling-user-provided-tables.patch [RHEL-21705] - kvm-smbios-don-t-check-type4-structures-in-legacy-mode.patch [RHEL-21705] - kvm-smbios-add-smbios_add_usr_blob_size-helper.patch [RHEL-21705] - kvm-smbios-rename-expose-structures-bitmaps-used-by-both.patch [RHEL-21705] - kvm-smbios-build-legacy-mode-code-only-for-pc-machine.patch [RHEL-21705] - kvm-smbios-handle-errors-consistently.patch [RHEL-21705] - kvm-smbios-get-rid-of-global-smbios_ep_type.patch [RHEL-21705] - kvm-smbios-clear-smbios_type4_count-before-building-tabl.patch [RHEL-21705] - kvm-smbios-extend-smbios-entry-point-type-with-auto-valu.patch [RHEL-21705] - kvm-smbios-in-case-of-entry-point-is-auto-try-to-build-v.patch [RHEL-21705] - kvm-smbios-error-out-when-building-type-4-table-is-not-p.patch [RHEL-21705] - kvm-pc-q35-set-SMBIOS-entry-point-type-to-auto-by-defaul.patch [RHEL-21705] - Resolves: RHEL-19629 (CVE-2023-6683 qemu-kvm: QEMU: VNC: NULL pointer dereference in qemu_clipboard_request() [rhel-9]) - Resolves: RHEL-21705 (pc-q35-rhel9.4.0 does not provide proper computer information)
108 lines
4.2 KiB
Diff
108 lines
4.2 KiB
Diff
From 097516bef2993d917e76d92066ca2eb067e45394 Mon Sep 17 00:00:00 2001
|
|
From: Fiona Ebner <f.ebner@proxmox.com>
|
|
Date: Wed, 24 Jan 2024 11:57:48 +0100
|
|
Subject: [PATCH 01/20] ui/clipboard: mark type as not available when there is
|
|
no data
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Jon Maloy <jmaloy@redhat.com>
|
|
RH-MergeRequest: 228: ui/clipboard: mark type as not available when there is no data
|
|
RH-Jira: RHEL-19629
|
|
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
RH-Acked-by: Gerd Hoffmann <None>
|
|
RH-Commit: [1/2] 74ded03d6376f9693733d673502219f76eab7099 (jmaloy/jmaloy-qemu-kvm-2)
|
|
|
|
JIRA: https://issues.redhat.com/browse/RHEL-19629
|
|
CVE: CVE-2023-6683
|
|
Upstream: Merged
|
|
|
|
commit 405484b29f6548c7b86549b0f961b906337aa68a
|
|
Author: Fiona Ebner <f.ebner@proxmox.com>
|
|
Date: Wed Jan 24 11:57:48 2024 +0100
|
|
|
|
ui/clipboard: mark type as not available when there is no data
|
|
|
|
With VNC, a client can send a non-extended VNC_MSG_CLIENT_CUT_TEXT
|
|
message with len=0. In qemu_clipboard_set_data(), the clipboard info
|
|
will be updated setting data to NULL (because g_memdup(data, size)
|
|
returns NULL when size is 0). If the client does not set the
|
|
VNC_ENCODING_CLIPBOARD_EXT feature when setting up the encodings, then
|
|
the 'request' callback for the clipboard peer is not initialized.
|
|
Later, because data is NULL, qemu_clipboard_request() can be reached
|
|
via vdagent_chr_write() and vdagent_clipboard_recv_request() and
|
|
there, the clipboard owner's 'request' callback will be attempted to
|
|
be called, but that is a NULL pointer.
|
|
|
|
In particular, this can happen when using the KRDC (22.12.3) VNC
|
|
client.
|
|
|
|
Another scenario leading to the same issue is with two clients (say
|
|
noVNC and KRDC):
|
|
|
|
The noVNC client sets the extension VNC_FEATURE_CLIPBOARD_EXT and
|
|
initializes its cbpeer.
|
|
|
|
The KRDC client does not, but triggers a vnc_client_cut_text() (note
|
|
it's not the _ext variant)). There, a new clipboard info with it as
|
|
the 'owner' is created and via qemu_clipboard_set_data() is called,
|
|
which in turn calls qemu_clipboard_update() with that info.
|
|
|
|
In qemu_clipboard_update(), the notifier for the noVNC client will be
|
|
called, i.e. vnc_clipboard_notify() and also set vs->cbinfo for the
|
|
noVNC client. The 'owner' in that clipboard info is the clipboard peer
|
|
for the KRDC client, which did not initialize the 'request' function.
|
|
That sounds correct to me, it is the owner of that clipboard info.
|
|
|
|
Then when noVNC sends a VNC_MSG_CLIENT_CUT_TEXT message (it did set
|
|
the VNC_FEATURE_CLIPBOARD_EXT feature correctly, so a check for it
|
|
passes), that clipboard info is passed to qemu_clipboard_request() and
|
|
the original segfault still happens.
|
|
|
|
Fix the issue by handling updates with size 0 differently. In
|
|
particular, mark in the clipboard info that the type is not available.
|
|
|
|
While at it, switch to g_memdup2(), because g_memdup() is deprecated.
|
|
|
|
Cc: qemu-stable@nongnu.org
|
|
Fixes: CVE-2023-6683
|
|
Reported-by: Markus Frank <m.frank@proxmox.com>
|
|
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
|
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
Tested-by: Markus Frank <m.frank@proxmox.com>
|
|
Message-ID: <20240124105749.204610-1-f.ebner@proxmox.com>
|
|
|
|
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
---
|
|
ui/clipboard.c | 12 +++++++++---
|
|
1 file changed, 9 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/ui/clipboard.c b/ui/clipboard.c
|
|
index 3d14bffaf8..b3f6fa3c9e 100644
|
|
--- a/ui/clipboard.c
|
|
+++ b/ui/clipboard.c
|
|
@@ -163,9 +163,15 @@ void qemu_clipboard_set_data(QemuClipboardPeer *peer,
|
|
}
|
|
|
|
g_free(info->types[type].data);
|
|
- info->types[type].data = g_memdup(data, size);
|
|
- info->types[type].size = size;
|
|
- info->types[type].available = true;
|
|
+ if (size) {
|
|
+ info->types[type].data = g_memdup2(data, size);
|
|
+ info->types[type].size = size;
|
|
+ info->types[type].available = true;
|
|
+ } else {
|
|
+ info->types[type].data = NULL;
|
|
+ info->types[type].size = 0;
|
|
+ info->types[type].available = false;
|
|
+ }
|
|
|
|
if (update) {
|
|
qemu_clipboard_update(info);
|
|
--
|
|
2.39.3
|
|
|