From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org
Cc: den@openvz.org, qemu-stable@nongnu.org,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH 5/6] io/channel-websock: do not lose QIO_CHANNEL_ERR_BLOCK while reading
Date: Mon, 31 Aug 2026 12:01:50 +0200 [thread overview]
Message-ID: <20260831100151.914178-6-den@openvz.org> (raw)
In-Reply-To: <20260831100151.914178-1-den@openvz.org>
From: Denis V. Lunev <den@openvz.org>
qio_channel_websock_handshake_read() folds every negative return from
qio_channel_read() into -1. QIO_CHANNEL_ERR_BLOCK leaves errp unset, so
qio_channel_websock_handshake_io() then hands a NULL Error to
error_get_pretty() and QEMU dies.
The master channel is non-blocking and, for a wss:// client, is a TLS
channel. A G_IO_IN wakeup carrying only part of a TLS record makes
gnutls report EAGAIN, which is all it takes to reach this before the
client has authenticated.
ERR_BLOCK here means the headers are not complete yet, which is what a
0 return already tells the caller. Report it that way and keep waiting.
The watch is level triggered, so an incomplete record sitting in the
socket spins the main loop until the rest of it arrives. That is
bounded by the round trip and is what every reader layered over TLS
already does.
Fixes: 2d1d0e70cf3e ("io: add QIOChannelWebsock class")
Cc: qemu-stable@nongnu.org
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
io/channel-websock.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/io/channel-websock.c b/io/channel-websock.c
index 8f27b1f12b..461abcae48 100644
--- a/io/channel-websock.c
+++ b/io/channel-websock.c
@@ -492,6 +492,9 @@ static int qio_channel_websock_handshake_read(QIOChannelWebsock *ioc,
buffer_reserve(&ioc->encinput, want);
ret = qio_channel_read(ioc->master,
(char *)buffer_end(&ioc->encinput), want, errp);
+ if (ret == QIO_CHANNEL_ERR_BLOCK) {
+ return 0;
+ }
if (ret < 0) {
return -1;
}
--
2.53.0
next prev parent reply other threads:[~2026-08-31 10:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 10:01 [PATCH 0/6] io/channel-websock: fix an unauthenticated crash in the handshake Denis V. Lunev
2026-08-31 10:01 ` [PATCH 1/6] io/channel-socket: do not treat a zero length write as an error Denis V. Lunev
2026-09-01 17:31 ` Daniel P. Berrangé
2026-08-31 10:01 ` [PATCH 2/6] io/channel-websock: send an HTTP 400 when the greeting has no space Denis V. Lunev
2026-09-01 17:23 ` Daniel P. Berrangé
2026-08-31 10:01 ` [PATCH 3/6] io/channel-websock: handle a blocked write during the handshake Denis V. Lunev
2026-09-01 17:24 ` Daniel P. Berrangé
2026-08-31 10:01 ` [PATCH 4/6] tests/unit: add websock handshake test Denis V. Lunev
2026-09-01 17:25 ` Daniel P. Berrangé
2026-08-31 10:01 ` Denis V. Lunev [this message]
2026-09-01 17:26 ` [PATCH 5/6] io/channel-websock: do not lose QIO_CHANNEL_ERR_BLOCK while reading Daniel P. Berrangé
2026-08-31 10:01 ` [PATCH 6/6] tests/unit: cover blocked IO during the websock handshake Denis V. Lunev
2026-09-01 17:30 ` Daniel P. Berrangé
2026-08-31 11:29 ` [PATCH 0/6] io/channel-websock: fix an unauthenticated crash in the handshake marcandre.lureau
2026-08-31 11:33 ` Denis V. Lunev
2026-09-01 17:54 ` Daniel P. Berrangé
2026-09-02 10:19 ` Mauro Matteo Cascella
2026-09-01 17:43 ` Daniel P. Berrangé
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=20260831100151.914178-6-den@openvz.org \
--to=den@openvz.org \
--cc=berrange@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.