From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
devel@lists.libvirt.org,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
qemu-stable@nongnu.org, "Denis V. Lunev" <den@openvz.org>
Subject: [PULL 04/13] io/channel-socket: do not treat a zero length write as an error
Date: Fri, 4 Sep 2026 11:59:20 +0100 [thread overview]
Message-ID: <20260904105929.3450663-5-berrange@redhat.com> (raw)
In-Reply-To: <20260904105929.3450663-1-berrange@redhat.com>
From: Denis V. Lunev <den@openvz.org>
qio_channel_socket_writev() checks "ret <= 0" after sendmsg(). A zero
length iovec is written successfully and returns 0, so the success
falls into the errno switch, which acts on whatever the last failing
syscall left in errno. A stale EAGAIN turns it into
QIO_CHANNEL_ERR_BLOCK with errp untouched, and a caller which treats
every negative return as fatal then passes a NULL Error to
error_get_pretty(). The websocket handshake does exactly that, so an
unauthenticated client crashes QEMU during the greeting.
Returning 0 is safe for callers which loop until everything is
written. qio_channel_writev_full_all() has no zero progress guard, but
iov_copy() yields no entries for a zero length write, so that loop is
never entered. A connected stream socket returns 0 only when there is
nothing to send.
The WIN32 implementation in the same file uses "ret < 0".
Fixes: CVE-2026-84788
Fixes: 559607ea173a ("io: add QIOChannelSocket class")
Cc: qemu-stable@nongnu.org
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
io/channel-socket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io/channel-socket.c b/io/channel-socket.c
index 12773b832c..7920cee639 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -667,7 +667,7 @@ static ssize_t qio_channel_socket_writev(QIOChannel *ioc,
retry:
ret = sendmsg(sioc->fd, &msg, sflags);
- if (ret <= 0) {
+ if (ret < 0) {
switch (errno) {
case EAGAIN:
return QIO_CHANNEL_ERR_BLOCK;
--
2.55.0
next prev parent reply other threads:[~2026-09-04 11:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 10:59 [PULL 00/13] Misc fixes patches Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 01/13] crypto: Use g_autofree Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 02/13] crypto/x509-utils: don't double set errp Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 03/13] crypto/x509-utils: propagate the error Daniel P. Berrangé
2026-09-04 10:59 ` Daniel P. Berrangé [this message]
2026-09-04 10:59 ` [PULL 05/13] io/channel-websock: send an HTTP 400 when the greeting has no space Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 06/13] io/channel-websock: handle a blocked write during the handshake Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 07/13] tests/unit: add websock handshake test Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 08/13] io/channel-websock: do not lose QIO_CHANNEL_ERR_BLOCK while reading Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 09/13] tests/unit: cover blocked IO during the websock handshake Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 10/13] crypto: deprecate the AF_ALG crypto backend Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 11/13] gitlab: use --emacs --quiet for checkpatch.pl instead of --terse Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 12/13] configure: correctly honour --disable-containers Daniel P. Berrangé
2026-09-04 10:59 ` [PULL 13/13] docs/system/security: exclude uninitialized stack variables as bugs Daniel P. Berrangé
2026-09-04 12:19 ` [PULL 00/13] Misc fixes patches 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=20260904105929.3450663-5-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=den@openvz.org \
--cc=devel@lists.libvirt.org \
--cc=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pierrick.bouvier@oss.qualcomm.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.