All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: zoudongjie <zoudongjie@huawei.com>,
	qemu-devel@nongnu.org, marcandre.lureau@redhat.com,
	alex.chen@huawei.com, chenjianfei3@huawei.com,
	eric.fangyi@huawei.com, luolongmin@huawei.com,
	mujinsheng@huawei.com, qemu-block@nongnu.org,
	qemu-stable@nongnu.org, renxuming@huawei.com,
	suxiaodong1@huawei.com, wangjian161@huawei.com,
	wangyan122@huawei.com, yebiaoxiang@huawei.com,
	yangming73@huawei.com, zhuyangyang14@huawei.com
Subject: Re: [PATCH] vnc: Fix memory leak during VNC tls authentication
Date: Wed, 7 Jan 2026 16:11:04 +0000	[thread overview]
Message-ID: <aV6FmB2Wzzkwa2Lh@redhat.com> (raw)
In-Reply-To: <aMqBlebG_tVzubhe@redhat.com>

On Wed, Sep 17, 2025 at 10:38:29AM +0100, Daniel P. Berrangé wrote:
> On Tue, Sep 16, 2025 at 09:41:53PM +0800, zoudongjie via wrote:
> > When qemu is performing a TLS handshake for VNC, it will monitor vs->sioc
> > in the qio_channel_tls_handshake_task. If the number of concurrent VNC
> > connections exceeds the maximum number allowed by qemu, vnc_connect will
> > traverse all connection requests in share mode VNC_SHARE_MODE_CONNECTING
> > and disconnect the first one.
> > 
> > If the disconnected request has not yet entered qio_channel_tls_handshake_io,
> > it will cause the data pointer allocated in qio_channel_tls_handshake_task
> > to leak directly, leading to an indirect leak of the task and its associated
> > pointers.
> 
> The qio_channel_tls_close method will cancel the pending handshake by
> calling g_clear_handle_id. The problem is that when we do that, we fail
> to release the QIOTask object because that is only freed when
> qio_channel_tls_handshake is called on completion triggering use of
> qio_task_complete.
> 
> The problem here is that we broadly mis-used the APIs for sources...
> 
> > @@ -201,13 +219,23 @@ static void qio_channel_tls_handshake_task(QIOChannelTLS *ioc,
> >          }
> >  
> >          trace_qio_channel_tls_handshake_pending(ioc, status);
> > -        ioc->hs_ioc_tag =
> > -            qio_channel_add_watch_full(ioc->master,
> > -                                       condition,
> > -                                       qio_channel_tls_handshake_io,
> > -                                       data,
> > -                                       NULL,
> > -                                       context);
> 
> ...instead of NULL we should have passed a method that can free
> the 'data' object there, as well as the QIOTask that 'data'
> contains a reference to.
> 
> The qio_task_complete method should not then free the task.

A fix for this flaw was implemented here:

  https://lists.nongnu.org/archive/html/qemu-devel/2026-01/msg00778.html

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



      reply	other threads:[~2026-01-07 16:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16 13:41 [PATCH] vnc: Fix memory leak during VNC tls authentication zoudongjie via
2025-09-17  9:38 ` Daniel P. Berrangé
2026-01-07 16:11   ` Daniel P. Berrangé [this message]

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=aV6FmB2Wzzkwa2Lh@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.chen@huawei.com \
    --cc=chenjianfei3@huawei.com \
    --cc=eric.fangyi@huawei.com \
    --cc=luolongmin@huawei.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mujinsheng@huawei.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=renxuming@huawei.com \
    --cc=suxiaodong1@huawei.com \
    --cc=wangjian161@huawei.com \
    --cc=wangyan122@huawei.com \
    --cc=yangming73@huawei.com \
    --cc=yebiaoxiang@huawei.com \
    --cc=zhuyangyang14@huawei.com \
    --cc=zoudongjie@huawei.com \
    /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.