From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fC05R-0007NS-8y for qemu-devel@nongnu.org; Fri, 27 Apr 2018 05:54:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fC05Q-0001eI-Jx for qemu-devel@nongnu.org; Fri, 27 Apr 2018 05:54:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36838 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fC05Q-0001e3-E6 for qemu-devel@nongnu.org; Fri, 27 Apr 2018 05:54:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAE3B722FC for ; Fri, 27 Apr 2018 09:54:39 +0000 (UTC) From: Gerd Hoffmann Date: Fri, 27 Apr 2018 11:54:29 +0200 Message-Id: <20180427095434.14013-2-kraxel@redhat.com> In-Reply-To: <20180427095434.14013-1-kraxel@redhat.com> References: <20180427095434.14013-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 1/6] vnc: fix use-after-free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eric Blake , Markus Armbruster , Alex Williamson , Gerd Hoffmann When vnc_client_read() return value is -1 vs is not valid any more. Fixes: d49b87f0d1e0520443a990fc610d0f02bc63c556 Reported-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Marc-Andr=C3=A9 Lureau Tested-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20180420084820.3873-1-kraxel@redhat.com --- ui/vnc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index e164eb798c..5526e54f48 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1539,13 +1539,14 @@ gboolean vnc_client_io(QIOChannel *ioc G_GNUC_UNU= SED, VncState *vs =3D opaque; if (condition & G_IO_IN) { if (vnc_client_read(vs) < 0) { - goto end; + /* vs is free()ed here */ + return TRUE; } } if (condition & G_IO_OUT) { vnc_client_write(vs); } -end: + if (vs->disconnecting) { if (vs->ioc_tag !=3D 0) { g_source_remove(vs->ioc_tag); --=20 2.9.3