ui/clipboard: avoid crash upon request when clipboard peer is not initialized
PATCH 1/1 ui/clipboard: avoid crash upon request when clipboard peer is not initialized
With VNC, it can be that a client sends a VNC_MSG_CLIENT_CUT_TEXT message before sending a VNC_MSG_CLIENT_SET_ENCODINGS message with VNC_ENCODING_CLIPBOARD_EXT for configuring the clipboard extension.
This means that qemu_clipboard_request() can be reached (via vnc_client_cut_text_ext()) before vnc_server_cut_text_caps() was called and had the chance to initialize the clipboard peer. In that case, info->owner->request is NULL instead of a function and so attempting to call it in qemu_clipboard_request() results in a segfault.
In particular, this can happen when using the KRDC (22.12.3) VNC client on Wayland.
It is not enough to check in ui/vnc.c's protocol_client_msg() if the VNC_FEATURE_CLIPBOARD_EXT feature is enabled before handling an extended clipboard message with vnc_client_cut_text_ext(), because of the following scenario 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 feature correctly, so the check added by your patch passes), that clipboard info is passed to qemu_clipboard_request() and the original segfault still happens.
---
This is just a minimal fix. Happy to add some warning/error to not hide the issue with the missing initialization completely and/or go for a different approach with a check somewhere in the VNC code.
ui/clipboard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ui/clipboard.c +2 -1
@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ; info->types[type].requested = true;
Signature · 1 line
2.39.2
Am 12.01.24 um 14:55 schrieb Fiona Ebner:
Quoted 3 lines
Then when noVNC sends a
VNC_MSG_CLIENT_CUT_TEXTmessage (it did set the feature correctly, so the check added by your patch passes),
Sorry, forgot to adapt this part. This should read "it did set the VNC_FEATURE_CLIPBOARD_EXT feature correctly, so a check for it passes".
Quoted 4 lines
that
clipboard info is passed toqemu_clipboard_request()and the original segfault still happens.
Hi
Quoted 57 lines · Fiona Ebner
With VNC, it can be that a client sends a
VNC_MSG_CLIENT_CUT_TEXTmessage before sending aVNC_MSG_CLIENT_SET_ENCODINGSmessage withVNC_ENCODING_CLIPBOARD_EXTfor configuring the clipboard extension.This means that
qemu_clipboard_request()can be reached (viavnc_client_cut_text_ext()) beforevnc_server_cut_text_caps()was called and had the chance to initialize the clipboard peer. In that case,info->owner->requestis NULL instead of a function and so attempting to call it inqemu_clipboard_request()results in a segfault.In particular, this can happen when using the KRDC (22.12.3) VNC client on Wayland.
It is not enough to check in ui/vnc.c's
protocol_client_msg()if theVNC_FEATURE_CLIPBOARD_EXTfeature is enabled before handling an extended clipboard message withvnc_client_cut_text_ext(), because of the following scenario with two clients (say noVNC and KRDC):The noVNC client sets the extension
VNC_FEATURE_CLIPBOARD_EXTand initializes its cbpeer.The KRDC client does not, but triggers a
vnc_client_cut_text()(note it's not the_extvariant)). There, a new clipboard info with it as the 'owner' is created and viaqemu_clipboard_set_data()is called, which in turn callsqemu_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 setvs->cbinfofor 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_TEXTmessage (it did set the feature correctly, so the check added by your patch passes), that clipboard info is passed toqemu_clipboard_request()and the original segfault still happens.Fixes CVE-2023-6683Reported-by Markus Frank <[email protected]>Signed-off-by Fiona Ebner <[email protected]>Tested-by Markus Frank <[email protected]>---
This is just a minimal fix. Happy to add some warning/error to not hide the issue with the missing initialization completely and/or go for a different approach with a check somewhere in the VNC code.
ui/clipboard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)ui/clipboard.c +0
-0
ui/clipboard.c void qemu_clipboard_request(QemuClipboardInfo *info, · line 134
Quoted 7 lines
ui/clipboard.c +2
-1@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ;
While that fixes the crash, I think we should handle the situation earlier. A clipboard peer shouldn't be allowed to hold the clipboard if it doesn't have the data available or a "request" callback set.
Iow, we should have an assert(info->owner->request != NULL) here instead.
Quoted 6 lines
ui/clipboard.c +0
-1info->types[type].requested = true; --2.39.2
Signature · 1 line
Marc-André Lureau
Am 14.01.24 um 14:51 schrieb Marc-André Lureau:
Quoted 18 lines
ui/clipboard.c void qemu_clipboard_request(QemuClipboardInfo *info, · line 134
Quoted 13 lines
ui/clipboard.c +2
-1@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ;While that fixes the crash, I think we should handle the situation earlier. A clipboard peer shouldn't be allowed to hold the clipboard if it doesn't have the data available or a "request" callback set.
Where should initialization of the cbpeer happen so that we are guaranteed to do it also for clients that do not set the VNC_FEATURE_CLIPBOARD_EXT feature? Can the vnc_clipboard_request function be re-used for clients without that feature or will it be necessary to add some kind of "dummy" request callback for those clients?
Quoted 2 lines
Iow, we should have an
assert(info->owner->request != NULL)here instead.
Your choice of course, but it would be a crash again should the issue ever re-appear. Would error message (so the issue gets noticed) + return be an option too?
Best Regards,
Fiona
Hi
Quoted 21 lines · Fiona Ebner
Am 14.01.24 um 14:51 schrieb Marc-André Lureau:
Quoted 18 lines
ui/clipboard.c void qemu_clipboard_request(QemuClipboardInfo *info, · line 134
Quoted 13 lines
ui/clipboard.c +2
-1@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ;While that fixes the crash, I think we should handle the situation earlier. A clipboard peer shouldn't be allowed to hold the clipboard if it doesn't have the data available or a "request" callback set.
Quoted 5 lines
Where should initialization of the cbpeer happen so that we are guaranteed to do it also for clients that do not set the
VNC_FEATURE_CLIPBOARD_EXTfeature? Can thevnc_clipboard_requestfunction be re-used for clients without that feature or will it be necessary to add some kind of "dummy" request callback for those clients?
qemu_clipboard_update() shouldn't accept info as current clipboard if the owner doesn't have the data available or a "request" callback set. This should also be assert() somehow and handled earlier.
In vnc_client_cut_text_ext() we could detect that situation, but with Daniel's "[PATCH] ui: reject extended clipboard message if not activated", this shouldn't happen anymore iiuc.
Quoted 10 lines
Quoted 3 lines
Iow, we should have an
assert(info->owner->request != NULL)here instead.Your choice of course, but it would be a crash again should the issue ever re-appear. Would error message (so the issue gets noticed) + return be an option too?
Best Regards,
Fiona
Signature · 1 line
Marc-André Lureau
Am 15.01.24 um 12:15 schrieb Marc-André Lureau:
Quoted 30 lines
Hi
Quoted 21 lines · Fiona Ebner
Am 14.01.24 um 14:51 schrieb Marc-André Lureau:
Quoted 18 lines
ui/clipboard.c void qemu_clipboard_request(QemuClipboardInfo *info, · line 134
Quoted 13 lines
ui/clipboard.c +2
-1@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ;While that fixes the crash, I think we should handle the situation earlier. A clipboard peer shouldn't be allowed to hold the clipboard if it doesn't have the data available or a "request" callback set.
Quoted 5 lines
Where should initialization of the cbpeer happen so that we are guaranteed to do it also for clients that do not set the
VNC_FEATURE_CLIPBOARD_EXTfeature? Can thevnc_clipboard_requestfunction be re-used for clients without that feature or will it be necessary to add some kind of "dummy" request callback for those clients?
Quoted 4 lines
qemu_clipboard_update()shouldn't accept info as current clipboard if the owner doesn't have the data available or a "request" callback set. This should also beassert()somehow and handled earlier.
The request callback is only initialized in vnc_server_cut_text_caps() when the VNC_FEATURE_CLIPBOARD_EXT is enabled. AFAIU, it's perfectly fine for clients to use the clipboard with non-extended messages and qemu_clipboard_update() should (and currently does) accept those.
Quoted 4 lines
In
vnc_client_cut_text_ext()we could detect that situation, but with Daniel's "[PATCH] ui: reject extended clipboard message if not activated", this shouldn't happen anymore iiuc.
Daniel's patch doesn't change the behavior for non-extended messages. The problem can still happen with two VNC clients. This is the scenario described in the lower half of my commit message (and why Daniel mentions in his patch that it's not sufficient to fix the CVE).
In short: client A does not set the VNC_FEATURE_CLIPBOARD_EXT feature and then uses a non-extended VNC_MSG_CLIENT_CUT_TEXT message. This leads to vnc_client_cut_text() being called and setting the clipboard info referencing that client. But here, no request callback is initialized, that only happens in vnc_server_cut_text_caps() when the VNC_FEATURE_CLIPBOARD_EXT is enabled.
When client B does set the VNC_FEATURE_CLIPBOARD_EXT feature and does send an extended VNC_MSG_CLIENT_CUT_TEXT message, the request callback will be attempted but it isn't set.
Best Regards,
Fiona
Hi
Quoted 59 lines · Fiona Ebner
Am 15.01.24 um 12:15 schrieb Marc-André Lureau:
Quoted 30 lines
Hi
Quoted 21 lines · Fiona Ebner
Am 14.01.24 um 14:51 schrieb Marc-André Lureau:
Quoted 18 lines
ui/clipboard.c void qemu_clipboard_request(QemuClipboardInfo *info, · line 134
Quoted 13 lines
ui/clipboard.c +2
-1@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ;While that fixes the crash, I think we should handle the situation earlier. A clipboard peer shouldn't be allowed to hold the clipboard if it doesn't have the data available or a "request" callback set.
Quoted 5 lines
Where should initialization of the cbpeer happen so that we are guaranteed to do it also for clients that do not set the
VNC_FEATURE_CLIPBOARD_EXTfeature? Can thevnc_clipboard_requestfunction be re-used for clients without that feature or will it be necessary to add some kind of "dummy" request callback for those clients?Quoted 4 lines
qemu_clipboard_update()shouldn't accept info as current clipboard if the owner doesn't have the data available or a "request" callback set. This should also beassert()somehow and handled earlier.The request callback is only initialized in
vnc_server_cut_text_caps()when theVNC_FEATURE_CLIPBOARD_EXTis enabled. AFAIU, it's perfectly fine for clients to use the clipboard with non-extended messages andqemu_clipboard_update()should (and currently does) accept those.Quoted 4 lines
In
vnc_client_cut_text_ext()we could detect that situation, but with Daniel's "[PATCH] ui: reject extended clipboard message if not activated", this shouldn't happen anymore iiuc.Daniel's patch doesn't change the behavior for non-extended messages. The problem can still happen with two VNC clients. This is the scenario described in the lower half of my commit message (and why Daniel mentions in his patch that it's not sufficient to fix the CVE).
In short: client A does not set the
VNC_FEATURE_CLIPBOARD_EXTfeature and then uses a non-extendedVNC_MSG_CLIENT_CUT_TEXTmessage. This leads tovnc_client_cut_text()being called and setting the clipboard info referencing that client. But here, no request callback is initialized, that only happens invnc_server_cut_text_caps()when theVNC_FEATURE_CLIPBOARD_EXTis enabled.
Quoted 4 lines
When client B does set the
VNC_FEATURE_CLIPBOARD_EXTfeature and does send an extendedVNC_MSG_CLIENT_CUT_TEXTmessage, the request callback will be attempted but it isn't set.
The trouble is when qemu_clipboard_update() is called without data & without a request callback set. We shouldn't allow that as we have no means to get the clipboard data then.
Signature · 1 line
Marc-André Lureau
Am 15.01.24 um 12:33 schrieb Marc-André Lureau:
Quoted 62 lines
Hi
Quoted 59 lines · Fiona Ebner
Am 15.01.24 um 12:15 schrieb Marc-André Lureau:
Quoted 30 lines
Hi
Quoted 21 lines · Fiona Ebner
Am 14.01.24 um 14:51 schrieb Marc-André Lureau:
Quoted 18 lines
ui/clipboard.c void qemu_clipboard_request(QemuClipboardInfo *info, · line 134
Quoted 13 lines
ui/clipboard.c +2
-1@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ;While that fixes the crash, I think we should handle the situation earlier. A clipboard peer shouldn't be allowed to hold the clipboard if it doesn't have the data available or a "request" callback set.
Quoted 5 lines
Where should initialization of the cbpeer happen so that we are guaranteed to do it also for clients that do not set the
VNC_FEATURE_CLIPBOARD_EXTfeature? Can thevnc_clipboard_requestfunction be re-used for clients without that feature or will it be necessary to add some kind of "dummy" request callback for those clients?Quoted 4 lines
qemu_clipboard_update()shouldn't accept info as current clipboard if the owner doesn't have the data available or a "request" callback set. This should also beassert()somehow and handled earlier.The request callback is only initialized in
vnc_server_cut_text_caps()when theVNC_FEATURE_CLIPBOARD_EXTis enabled. AFAIU, it's perfectly fine for clients to use the clipboard with non-extended messages andqemu_clipboard_update()should (and currently does) accept those.Quoted 4 lines
In
vnc_client_cut_text_ext()we could detect that situation, but with Daniel's "[PATCH] ui: reject extended clipboard message if not activated", this shouldn't happen anymore iiuc.Daniel's patch doesn't change the behavior for non-extended messages. The problem can still happen with two VNC clients. This is the scenario described in the lower half of my commit message (and why Daniel mentions in his patch that it's not sufficient to fix the CVE).
In short: client A does not set the
VNC_FEATURE_CLIPBOARD_EXTfeature and then uses a non-extendedVNC_MSG_CLIENT_CUT_TEXTmessage. This leads tovnc_client_cut_text()being called and setting the clipboard info referencing that client. But here, no request callback is initialized, that only happens invnc_server_cut_text_caps()when theVNC_FEATURE_CLIPBOARD_EXTis enabled.
Quoted 9 lines
Quoted 4 lines
When client B does set the
VNC_FEATURE_CLIPBOARD_EXTfeature and does send an extendedVNC_MSG_CLIENT_CUT_TEXTmessage, the request callback will be attempted but it isn't set.The trouble is when
qemu_clipboard_update()is called without data & without a request callback set. We shouldn't allow that as we have no means to get the clipboard data then.
In the above scenario, I'm pretty sure there is data when qemu_clipboard_update() is called. Just no request callback. If we'd reject this, won't that break clients that do not set the VNC_FEATURE_CLIPBOARD_EXT feature and only use non-extended VNC_MSG_CLIENT_CUT_TEXT messages?
Best Regards,
Fiona
Hi
Quoted 74 lines · Fiona Ebner
Am 15.01.24 um 12:33 schrieb Marc-André Lureau:
Quoted 62 lines
Hi
Quoted 59 lines · Fiona Ebner
Am 15.01.24 um 12:15 schrieb Marc-André Lureau:
Quoted 30 lines
Hi
Quoted 21 lines · Fiona Ebner
Am 14.01.24 um 14:51 schrieb Marc-André Lureau:
Quoted 18 lines
ui/clipboard.c void qemu_clipboard_request(QemuClipboardInfo *info, · line 134
Quoted 13 lines
ui/clipboard.c +2
-1@@ -129,7 +129,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,if (info->types[type].data || info->types[type].requested || !info->types[type].available || - !info->owner) + !info->owner || + !info->owner->request)return ;While that fixes the crash, I think we should handle the situation earlier. A clipboard peer shouldn't be allowed to hold the clipboard if it doesn't have the data available or a "request" callback set.
Quoted 5 lines
Where should initialization of the cbpeer happen so that we are guaranteed to do it also for clients that do not set the
VNC_FEATURE_CLIPBOARD_EXTfeature? Can thevnc_clipboard_requestfunction be re-used for clients without that feature or will it be necessary to add some kind of "dummy" request callback for those clients?Quoted 4 lines
qemu_clipboard_update()shouldn't accept info as current clipboard if the owner doesn't have the data available or a "request" callback set. This should also beassert()somehow and handled earlier.The request callback is only initialized in
vnc_server_cut_text_caps()when theVNC_FEATURE_CLIPBOARD_EXTis enabled. AFAIU, it's perfectly fine for clients to use the clipboard with non-extended messages andqemu_clipboard_update()should (and currently does) accept those.Quoted 4 lines
In
vnc_client_cut_text_ext()we could detect that situation, but with Daniel's "[PATCH] ui: reject extended clipboard message if not activated", this shouldn't happen anymore iiuc.Daniel's patch doesn't change the behavior for non-extended messages. The problem can still happen with two VNC clients. This is the scenario described in the lower half of my commit message (and why Daniel mentions in his patch that it's not sufficient to fix the CVE).
In short: client A does not set the
VNC_FEATURE_CLIPBOARD_EXTfeature and then uses a non-extendedVNC_MSG_CLIENT_CUT_TEXTmessage. This leads tovnc_client_cut_text()being called and setting the clipboard info referencing that client. But here, no request callback is initialized, that only happens invnc_server_cut_text_caps()when theVNC_FEATURE_CLIPBOARD_EXTis enabled.Quoted 9 lines
Quoted 4 lines
When client B does set the
VNC_FEATURE_CLIPBOARD_EXTfeature and does send an extendedVNC_MSG_CLIENT_CUT_TEXTmessage, the request callback will be attempted but it isn't set.The trouble is when
qemu_clipboard_update()is called without data & without a request callback set. We shouldn't allow that as we have no means to get the clipboard data then.
Quoted 5 lines
In the above scenario, I'm pretty sure there is data when
qemu_clipboard_update()is called. Just no request callback. If we'd reject this, won't that break clients that do not set theVNC_FEATURE_CLIPBOARD_EXTfeature and only use non-extendedVNC_MSG_CLIENT_CUT_TEXTmessages?
If "data" is already set, then qemu_clipboard_request() returns.
Inverting the condition I suggested above: it's allowed to be the clipboard owner if either "data" is set, or a request callback is set.
Signature · 1 line
Marc-André Lureau
Am 15.01.24 um 13:00 schrieb Marc-André Lureau:
Quoted 13 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
The trouble is when
qemu_clipboard_update()is called without data & without a request callback set. We shouldn't allow that as we have no means to get the clipboard data then.Quoted 5 lines
In the above scenario, I'm pretty sure there is data when
qemu_clipboard_update()is called. Just no request callback. If we'd reject this, won't that break clients that do not set theVNC_FEATURE_CLIPBOARD_EXTfeature and only use non-extendedVNC_MSG_CLIENT_CUT_TEXTmessages?
Quoted 5 lines
If "data" is already set, then
qemu_clipboard_request()returns.Inverting the condition I suggested above: it's allowed to be the clipboard owner if either "data" is set, or a request callback is set.
Oh, sorry. Yes, it seems the problematic case is where data is not set. But isn't that legitimate when clearing the clipboard? Or is a VNC_MSG_CLIENT_CUT_TEXT message not valid when len is 0 and should be rejected? In my testing KRDC does send such a message when the clipboard is cleared:
Quoted 4 lines
#1
0x0000558f1e6a0dacinvnc_client_cut_text(vs=0x558f207754d0, len=0,text=0x558f2046e008 "\003 \002\377\005") at ../ui/vnc-clipboard.c:313 #2 0x0000558f1e68e067 in protocol_client_msg (vs=0x558f207754d0, data=0x558f2046e000 "\006", len=8) at ../ui/vnc.c:2454
Your suggestion would disallow this for clients that do not set the VNC_FEATURE_CLIPBOARD_EXT feature (and only use non-extended VNC_MSG_CLIENT_CUT_TEXT messages).
Best Regards,
Fiona
Am 16.01.24 um 13:11 schrieb Fiona Ebner:
Quoted 26 lines
Am 15.01.24 um 13:00 schrieb Marc-André Lureau:
Quoted 13 lines
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
The trouble is when
qemu_clipboard_update()is called without data & without a request callback set. We shouldn't allow that as we have no means to get the clipboard data then.Quoted 5 lines
In the above scenario, I'm pretty sure there is data when
qemu_clipboard_update()is called. Just no request callback. If we'd reject this, won't that break clients that do not set theVNC_FEATURE_CLIPBOARD_EXTfeature and only use non-extendedVNC_MSG_CLIENT_CUT_TEXTmessages?Quoted 5 lines
If "data" is already set, then
qemu_clipboard_request()returns.Inverting the condition I suggested above: it's allowed to be the clipboard owner if either "data" is set, or a request callback is set.
Oh, sorry. Yes, it seems the problematic case is where data is not set. But isn't that legitimate when clearing the clipboard? Or is a
VNC_MSG_CLIENT_CUT_TEXTmessage not valid when len is 0 and should be rejected? In my testing KRDC does send such a message when the clipboard is cleared:
Quoted 9 lines
Quoted 4 lines
#1
0x0000558f1e6a0dacinvnc_client_cut_text(vs=0x558f207754d0, len=0,text=0x558f2046e008 "\003 \002\377\005") at ../ui/vnc-clipboard.c:313 #2 0x0000558f1e68e067 in protocol_client_msg (vs=0x558f207754d0, data=0x558f2046e000 "\006", len=8) at ../ui/vnc.c:2454Your suggestion would disallow this for clients that do not set the
VNC_FEATURE_CLIPBOARD_EXTfeature (and only use non-extendedVNC_MSG_CLIENT_CUT_TEXTmessages).
I noticed that there is yet another code path leading to qemu_clipboard_request() and dereferencing the NULL owner->request even if only non-extended VNC_MSG_CLIENT_CUT_TEXT messages are used:
Quoted 5 lines
Thread 1 "qemu-system-x86" hit Breakpoint 1,
vnc_client_cut_text(vs=0x5555593e6c00, len=0, text=0x5555575ea608 "404078,bus=ahci0.0,drive=drive-sata0,id=sata0,bootindex=100\377\001") at ../ui/vnc-clipboard.c:310(gdb) c
Continuing.
And later:
Quoted 30 lines
qemu_clipboard_request(info=0x555557e576e0, type=QEMU_CLIPBOARD_TYPE_TEXT) at../ui/clipboard.c:129
129 if (info->types[type].data ||
(gdb) p*info->owner
$65 = {name =0x0, notifier = {notify =0x0, node = {le_next=0x0,le_prev=0x0}}, request =0x0} (gdb) bt#0 qemu_clipboard_request (info=0x555557e576e0, type=QEMU_CLIPBOARD_TYPE_TEXT) at ../ui/clipboard.c:129 #1 0x00005555558952ce in vdagent_chr_recv_chunk (vd=0x555556f67800) at ../ui/vdagent.c:769 #2 vdagent_chr_write (chr=<optimized out>, buf=0x7fff4ab263e4 "", len=0) at ../ui/vdagent.c:840 #3 0x0000555555d98830 in qemu_chr_write_buffer (s=s@entry=0x555556f67800, buf=buf@entry=0x7fff4ab263c0 "\001", len=36, offset=offset@entry=0x7fffffffd030, write_all=false) at ../chardev/char.c:122 #4 0x0000555555d98c3c in qemu_chr_write (s=0x555556f67800, buf=buf@entry=0x7fff4ab263c0 "\001", len=len@entry=36, write_all=<optimized out>, write_all@entry=false) at ../chardev/char.c:186 #5 0x0000555555d9109f in qemu_chr_fe_write (be=be@entry=0x555556e59040, buf=buf@entry=0x7fff4ab263c0 "\001", len=len@entry=36) at ../chardev/char-fe.c:42 #6 0x0000555555900045 in flush_buf (port=0x555556e58f40, buf=0x7fff4ab263c0 "\001", len=36) at ../hw/char/virtio-console.c:63 #7 0x0000555555bea4f3 in do_flush_queued_data (port=0x555556e58f40, vq=0x555559272558, vdev=0x55555926a4d0) at ../hw/char/virtio-serial-bus.c:188#8
0x0000555555c201ffinvirtio_queue_notify_vq(vq=0x555559272558) at../hw/virtio/virtio.c:2268
#90x0000555555e36dd5inaio_dispatch_handler(ctx=ctx@entry=0x555556e51b10, node=0x7ffed812b9f0) at../util/aio-posix.c:372#100x0000555555e37662inaio_dispatch_handlers(ctx=0x555556e51b10) at../util/aio-posix.c:414
#11aio_dispatch(ctx=0x555556e51b10) at../util/aio-posix.c:424
#120x0000555555e4d44einaio_ctx_dispatch(source=<optimized out>, callback=<optimized out>, user_data=<optimized out>)at ../util/async.c:358#13
0x00007ffff753e7a9ing_main_context_dispatch() from/lib/x86_64-linux-gnu/libglib-2.0.so.0#140x0000555555e4ecb8inglib_pollfds_poll() at../util/main-loop.c:287
#15os_host_main_loop_wait(timeout=58675786) at../util/main-loop.c:310
#16main_loop_wait(nonblocking=nonblocking@entry=0) at../util/main-loop.c:589
#170x0000555555aa5f63inqemu_main_loop() at../system/runstate.c:791
#180x0000555555cadc16inqemu_default_main() at../system/main.c:37
#190x00007ffff60801cain__libc_start_call_main(main=main@entry=0x5555558819d0 <main>, argc=argc@entry=102,
Quoted 4 lines
argv=argv@entry=0x7fffffffd458) at ../sysdeps/nptl/libc_start_call_main.h:58 #20 0x00007ffff6080285 in __libc_start_main_impl (main=0x5555558819d0 <main>, argc=102, argv=0x7fffffffd458, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd448) at ../csu/libc-start.c:360#21
0x0000555555883581in_start()
So such non-extended VNC_MSG_CLIENT_CUT_TEXT messages with len=0 are already problematic. Is clearing the clipboard supposed to be done differently?
Your suggestion would prevent this scenario too. I'll send a patch with that shortly.
Best Regards,
Fiona