From patchwork Mon Jul 23 20:17:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10540991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41559112E for ; Mon, 23 Jul 2018 21:08:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 305FE284C9 for ; Mon, 23 Jul 2018 21:08:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24CC1284DC; Mon, 23 Jul 2018 21:08:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C7C18284D1 for ; Mon, 23 Jul 2018 21:08:10 +0000 (UTC) Received: from localhost ([::1]:36638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhi3t-00040y-Tx for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 17:08:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhJk-0002we-D5 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhJh-0004ht-3i for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:20:28 -0400 Received: from mail-oi0-x233.google.com ([2607:f8b0:4003:c06::233]:39356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhJg-0004h5-CV; Mon, 23 Jul 2018 16:20:24 -0400 Received: by mail-oi0-x233.google.com with SMTP id d189-v6so3482468oib.6; Mon, 23 Jul 2018 13:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aCrv7zeIBjjc2qT2uEGSz+lqDokwTYED+su3U1iCYzE=; b=iEeEVhSeVu8vb5D/8u8zxPg/qLi4Tg56Et+SdZwti8edWC1G/hpuxTHqokvtm7nmbr gjJaje8Pb68OkkI4PNsD02Syrp9dq0ts96wH8qi9ZBwHbCxa83FQB7eHtd8J6zC0PNEV wf5KNbGyvq7QvLNl57L02bWX+3TGLhGPrQKhsh3brHu9o2qZSnFJTj61atnVXX+aU2/g wItFpD+L3f+69/wkJgRU2TbEN+KX8IpXI/T6wzdnaRKCAcVpL3SaSjK6xrpzzLIMreMR L0jJ3OP6b2tH5iM5TYf636JPtbognYnKLkvxxu4L1kYaJssKgEsBhqX4v/1FzhUOWhzU JW4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=aCrv7zeIBjjc2qT2uEGSz+lqDokwTYED+su3U1iCYzE=; b=U2BrtJUY9bvoQ7pBnioz6K3ClHDxctT3gezvseE5ApkFv+W+tKLASAHC5+uFoOD3FC jB8OSFvMIa5IStOygHgVojHPSuT/lmwnHMKBh3Smb7T+uqwzbuX4yRMugwOEwQGdNm5T 6IShdXjqCecWZ8tWn/X7t7xt8J46renZl9cMBg89iwp2XFu1Si5e06K7uxAqgHmkd0JK glktfayIP4tSpUAXlvko6wa40N+ojG7wg0d7ob5vvMndwbyeolxWexjjH/QMyANM1rfe i1Bb3UJWgioIH0RegZOjwBFpqvW4GLjiCRxgdEW1yRLAU4jRB9OZ72aTEg2ylo7UJ5p/ qrFg== X-Gm-Message-State: AOUpUlGv6H0KTA3ZVOiqVgIW5AxPP4yJuoZrTNsilZKLVZr//zeu6gdX gg9Wa8jLOVL3fux90syUZU+dJaoDnrs= X-Google-Smtp-Source: AAOMgpfJwBY64XHfX3Btag/phUbKbHrKFmQcOjVlEF8oK9l0VhvGkeJg1ky9N0zzp3uZymAB3GLhWw== X-Received: by 2002:aca:856:: with SMTP id 83-v6mr254074oii.333.1532377222997; Mon, 23 Jul 2018 13:20:22 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id s124-v6sm6810178oia.51.2018.07.23.13.20.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:20:21 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:01 -0500 Message-Id: <20180723201748.25573-53-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::233 Subject: [Qemu-devel] [PATCH 52/99] vnc: fix use-after-free X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gerd Hoffmann When vnc_client_read() return value is -1 vs is not valid any more. Fixes: d49b87f0d1e0520443a990fc610d0f02bc63c556 Reported-by: Philippe Mathieu-Daudé Signed-off-by: Gerd Hoffmann Reviewed-by: Marc-André Lureau Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Tested-by: Marc-André Lureau Tested-by: Philippe Mathieu-Daudé Message-id: 20180420084820.3873-1-kraxel@redhat.com (cherry picked from commit 1bc3117abad28d6465ecdb2c944b22943df0e4f3) Signed-off-by: Michael Roth --- 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_UNUSED, VncState *vs = 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 != 0) { g_source_remove(vs->ioc_tag);