From: "Grant Millar | Cylo" <rid@cylo.io>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Subject: Re: [PATCH] ui/vnc: Fix NULL pointer dereference in vnc_disconnect_start
Date: Tue, 30 Sep 2025 11:41:50 +0100 [thread overview]
Message-ID: <CANdvy3c3bCN1km-oa3TY1it1H5qvNXMeM2zY18K1fM9gC5DPRA@mail.gmail.com> (raw)
In-Reply-To: <CAJ+F1CJwGZ-+dder5+icmuqSvtQ=fjce1zfrGKamYuYxVxOX9w@mail.gmail.com>
Sure, no problem. This is on 10.0.3 (Debian 1:10.0.3+ds-0+deb13u1).
Sometimes I have to run the reproducer a few times for the race
condition to occur.
#0 object_get_class (obj=obj@entry=0x0) at qom/object.c:1043
#1 0x0000556a3b671655 in QIO_CHANNEL_GET_CLASS (obj=0x0) at
./include/io/channel.h:29
#2 qio_channel_close (ioc=0x0, errp=0x0) at io/channel.c:380
#3 0x0000556a3b2036d9 in vnc_disconnect_start (vs=0x556a463d96a0) at
ui/vnc.c:1310
#4 0x0000556a3b2063d5 in vnc_disconnect_start (vs=0x556a463d96a0) at
ui/vnc.c:1398
#5 0x0000556a3b21b096 in vncws_handshake_done (task=<optimized out>,
user_data=0x556a463d96a0) at ui/vnc-ws.c:105
#6 0x0000556a3b673f54 in qio_task_complete (task=0x556a469a7fc0) at
io/task.c:197
#7 0x0000556a3b670a50 in qio_channel_websock_handshake_io
(ioc=0x556a45ec60e0, condition=<optimized out>,
user_data=0x556a469a7fc0) at io/channel-websock.c:588
#8 0x00007f4f6dca9385 in ??? () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#9 0x00007f4f6dcabc78 in g_main_context_dispatch () at
/lib/x86_64-linux-gnu/libglib-2.0.so.0
#10 0x0000556a3b8015b8 in glib_pollfds_poll () at util/main-loop.c:287
#11 os_host_main_loop_wait (timeout=0) at util/main-loop.c:310
#12 main_loop_wait (nonblocking=nonblocking@entry=0) at util/main-loop.c:589
#13 0x0000556a3b44b360 in qemu_main_loop () at system/runstate.c:835
#14 0x0000556a3b746cb0 in qemu_default_main (opaque=opaque@entry=0x0)
at system/main.c:50
#15 0x0000556a3b1b4319 in main (argc=<optimized out>, argv=<optimized
out>) at system/main.c:80
On Tue, 30 Sept 2025 at 11:38, Marc-André Lureau
<marcandre.lureau@gmail.com> wrote:
>
> Hi
>
> On Tue, Sep 30, 2025 at 1:59 PM Grant Millar | Cylo <rid@cylo.io> wrote:
> >
> > From 0d1c4ac000a66ef22b4a0cd0c4bedd840192096a Mon Sep 17 00:00:00 2001
> > From: Rid <rid@cylo.io>
> > Date: Tue, 30 Sep 2025 10:23:58 +0100
> > Subject: [PATCH] ui/vnc: Fix NULL pointer dereference in vnc_disconnect_start
> >
> > When a WebSocket connection fails during the handshake, vs->ioc can be
> > NULL when vnc_disconnect_start() is called, leading to a segmentation
> > fault when qio_channel_close() tries to dereference it.
> >
> > This can be reproduced by sending incomplete HTTP requests to the
> > WebSocket port:
> >
> > for i in {1..100}; do
> > (echo -n "GET / HTTP/1.1" && sleep 0.05) | nc -w 1 <IP> <PORT> &
> > done
> >
>
> I tried to reproduce without success.
>
> Could you provide a backtrace?
>
> > Add a NULL check before calling qio_channel_close() to prevent the crash.
> >
> > Signed-off-by: Rid <rid@cylo.io>
>
> Your mail is not properly formatted. git am fails.
> https://www.qemu.org/docs/master/devel/submitting-a-patch.html
>
>
> thanks
>
> > ---
> > ui/vnc.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/ui/vnc.c b/ui/vnc.c
> > index 77c823bf2e..1669ed1b80 100644
> > --- a/ui/vnc.c
> > +++ b/ui/vnc.c
> > @@ -1301,7 +1301,9 @@ static void vnc_disconnect_start(VncState *vs)
> > g_source_remove(vs->ioc_tag);
> > vs->ioc_tag = 0;
> > }
> > - qio_channel_close(vs->ioc, NULL);
> > + if (vs->ioc) {
> > + qio_channel_close(vs->ioc, NULL);
> > + }
> > vs->disconnecting = TRUE;
> > }
> >
> > --
> > 2.39.5
> >
>
>
> --
> Marc-André Lureau
next prev parent reply other threads:[~2025-09-30 13:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-30 9:35 [PATCH] ui/vnc: Fix NULL pointer dereference in vnc_disconnect_start Grant Millar | Cylo
2025-09-30 10:38 ` Marc-André Lureau
2025-09-30 10:41 ` Grant Millar | Cylo [this message]
2025-09-30 10:48 ` Daniel P. Berrangé
2025-09-30 10:46 ` 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=CANdvy3c3bCN1km-oa3TY1it1H5qvNXMeM2zY18K1fM9gC5DPRA@mail.gmail.com \
--to=rid@cylo.io \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).