TLS crash fix
The following changes since commit 802341823f1720511dd5cf53ae40285f7978c61b:
Merge tag 'pull-tcg-20230731' of https://gitlab.com/rth7680/qemu into staging (2023-07-31 14:02:51 -0700)
are available in the Git repository at:
https://gitlab.com/berrange/qemu tags/io-tls-hs-crash-pull-request
for you to fetch changes up to 10be627d2b5ec2d6b3dce045144aa739eef678b4:
io: remove io watch if TLS channel is closed during handshake (2023-08-01 18:45:27 +0100)
----------------------------------------------------------------
Fix crash during early close of TLS channel
----------------------------------------------------------------
Daniel P. Berrangé (1):
io: remove io watch if TLS channel is closed during handshake
include/io/channel-tls.h | 1 + io/channel-tls.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.41.0
[PULL 1/1] io: remove io watch if TLS channel is closed during handshake
The TLS handshake make take some time to complete, during which time an I/O watch might be registered with the main loop. If the owner of the I/O channel invokes qio_channel_close() while the handshake is waiting to continue the I/O watch must be removed. Failing to remove it will later trigger the completion callback which the owner is not expecting to receive. In the case of the VNC server, this results in a SEGV as vnc_disconnect_start() tries to shutdown a client connection that is already gone / NULL.
CVE-2023-3354
--- include/io/channel-tls.h | 1 + io/channel-tls.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)
include/io/channel-tls.h +1 -0
@@ -48,6 +48,7 @@ struct QIOChannelTLS {QIOChannel *master;QCryptoTLSSession *session;QIOChannelShutdown shutdown; +guint hs_ioc_tag; };/**
io/channel-tls.c +12 -6
@@ -198,12 +198,13 @@ static void qio_channel_tls_handshake_task(QIOChannelTLS *ioc, }trace_qio_channel_tls_handshake_pending (ioc, status); -qio_channel_add_watch_full (ioc->master, - condition, - qio_channel_tls_handshake_io, - data, -NULL , - context); + ioc->hs_ioc_tag = +qio_channel_add_watch_full (ioc->master, + condition, + qio_channel_tls_handshake_io, + data, +NULL , + context); } }
@@ -218,6 +219,7 @@ static gboolean qio_channel_tls_handshake_io(QIOChannel *ioc,QIOChannelTLS *tioc =QIO_CHANNEL_TLS (qio_task_get_source (task)); + tioc->hs_ioc_tag =0 ;g_free (data);qio_channel_tls_handshake_task (tioc, task, context);
@@ -378,6 +380,10 @@ static int qio_channel_tls_close(QIOChannel *ioc, {QIOChannelTLS *tioc =QIO_CHANNEL_TLS (ioc); +if (tioc->hs_ioc_tag) { +g_clear_handle_id (&tioc->hs_ioc_tag, g_source_remove); + } +return qio_channel_close (tioc->master, errp); }
Signature · 1 line
2.41.0
Richard Henderson
AppliedQuoted 6 lines · Daniel P. Berrangé
The following changes since commit
802341823f1720511dd5cf53ae40285f7978c61b:Merge tag 'pull-tcg-20230731' ofhttps://gitlab.com/rth7680/qemu into staging (2023-07-31 14:02:51 -0700)are available in the Git repository at:
Quoted 8 lines
https://gitlab.com/berrange/qemu tags/io-tls-hs-crash-pull-request
for you to fetch changes up to
10be627d2b5ec2d6b3dce045144aa739eef678b4:io: remove io watch if TLS channel is closed during handshake (2023-08-01 18:45:27 +0100)
----------------------------------------------------------------
Fix crash during early close of TLS channel
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/8.1 as appropriate.
r~