qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: qemu-devel@nongnu.org, qemu-stable <qemu-stable@nongnu.org>,
	"Grant Millar | Cylo" <rid@cylo.io>,
	"Marc-André Lureau" <marcandre.lureau@gmail.com>,
	"Eric Blake" <eblake@redhat.com>
Subject: Re: [PATCH v2 1/3] io: release active GSource in TLS channel finalizer
Date: Mon, 17 Nov 2025 08:55:07 +0000	[thread overview]
Message-ID: <aRri1UWjwIu03FQp@redhat.com> (raw)
In-Reply-To: <69002830-e7ce-4d52-b875-857a096e1a70@tls.msk.ru>

On Sat, Nov 15, 2025 at 01:01:29AM +0300, Michael Tokarev wrote:
> On 11/14/25 22:12, Michael Tokarev wrote:
> > On 10/3/25 18:02, Daniel P. Berrangé wrote:
> > > While code is supposed to call qio_channel_close() before releasing the
> > > last reference on an QIOChannel, this is not guaranteed. QIOChannelFile
> > > and QIOChannelSocket both cleanup resources in their finalizer if the
> > > close operation was missed.
> > > 
> > > This ensures the TLS channel will do the same failsafe cleanup.
> > > 
> > > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > > ---
> > >   io/channel-tls.c | 10 ++++++++++
> > >   1 file changed, 10 insertions(+)
> > > 
> > > diff --git a/io/channel-tls.c b/io/channel-tls.c
> > > index 7135896f79..bb460ca7e9 100644
> > > --- a/io/channel-tls.c
> > > +++ b/io/channel-tls.c
> > > @@ -342,6 +342,16 @@ static void qio_channel_tls_finalize(Object *obj)
> > >   {
> > >       QIOChannelTLS *ioc = QIO_CHANNEL_TLS(obj);
> > > +    if (ioc->hs_ioc_tag) {
> > > +        trace_qio_channel_tls_handshake_cancel(ioc);
> > > +        g_clear_handle_id(&ioc->hs_ioc_tag, g_source_remove);
> > > +    }
> > > +
> > > +    if (ioc->bye_ioc_tag) {
> > > +        trace_qio_channel_tls_bye_cancel(ioc);
> > > +        g_clear_handle_id(&ioc->bye_ioc_tag, g_source_remove);
> > > +    }
> > > +
> > >       object_unref(OBJECT(ioc->master));
> > >       qcrypto_tls_session_free(ioc->session);
> > >   }
> > 
> > This series should be relevant for 7.2.x qemu stable series too, it
> > looks like.  Except that 7.2 does not have ioc->bye_ioc_tag (which
> > comes from v9.2.0-1773-g30ee88622e "io: tls: Add qio_channel_tls_bye"),
> > and does not have trace_qio_channel_tls_handshake_cancel defined.
> 
> https://gitlab.com/mjt0k/qemu/-/commits/cebdbd038e44af56e74272924dc2bf595a51fd8f
> is what I did (4 commits from there).  I picked up a trivial change
> v8.2.0-1149-g003f15369d "io: add trace event when cancelling TLS
> handshake", and removed half of v10.1.0-1703-g2c147611cf56
> "io: release active GSource in TLS channel finalizer" (this one)
> which releases bye_ioc_tag.
> 
> The other (subsequent) two commits from this series are taken as-is.

Yep, that's all looking correct.

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:[~2025-11-17  8:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-03 15:02 [PATCH v2 0/3] io: fix crash in VNC websock server when client quits early Daniel P. Berrangé
2025-10-03 15:02 ` [PATCH v2 1/3] io: release active GSource in TLS channel finalizer Daniel P. Berrangé
2025-10-16 14:13   ` Eric Blake
2025-11-14 19:12   ` Michael Tokarev
2025-11-14 22:01     ` Michael Tokarev
2025-11-17  8:55       ` Daniel P. Berrangé [this message]
2025-10-03 15:02 ` [PATCH v2 2/3] io: move websock resource release to close method Daniel P. Berrangé
2025-10-16 14:15   ` Eric Blake
2025-10-03 15:02 ` [PATCH v2 3/3] io: fix use after free in websocket handshake code Daniel P. Berrangé
2025-10-16 14:19   ` Eric Blake
2025-10-26  8:02 ` [PATCH v2 0/3] io: fix crash in VNC websock server when client quits early Michael Tokarev
2025-10-27 10:18   ` 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=aRri1UWjwIu03FQp@redhat.com \
    --to=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=rid@cylo.io \
    /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).