From patchwork Mon Jan 18 15:53:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 8055681 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DD63CBEEE5 for ; Mon, 18 Jan 2016 15:54:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DE5B2045A for ; Mon, 18 Jan 2016 15:54:03 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 85FE720390 for ; Mon, 18 Jan 2016 15:54:02 +0000 (UTC) Received: from localhost ([::1]:60410 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLC81-0004d4-W4 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jan 2016 10:54:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLC7r-0004a7-M7 for qemu-devel@nongnu.org; Mon, 18 Jan 2016 10:53:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLC7o-0002NA-LS for qemu-devel@nongnu.org; Mon, 18 Jan 2016 10:53:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLC7o-0002Ml-Gg for qemu-devel@nongnu.org; Mon, 18 Jan 2016 10:53:48 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 1962F8F896; Mon, 18 Jan 2016 15:53:48 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-31.ams2.redhat.com [10.36.116.31]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0IFrkZi025926; Mon, 18 Jan 2016 10:53:47 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id AF69B801CE; Mon, 18 Jan 2016 16:53:45 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 18 Jan 2016 16:53:42 +0100 Message-Id: <1453132424-15520-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1453132424-15520-1-git-send-email-kraxel@redhat.com> References: <1453132424-15520-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wolfgang Bumiller , Gerd Hoffmann Subject: [Qemu-devel] [PULL 2/4] vnc: clear vs->tlscreds after unparenting it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wolfgang Bumiller This pointer should be cleared in vnc_display_close() otherwise a use-after-free can happen when when using the old style 'x509' and 'tls' options rather than a persistent tls-creds -object, by issuing monitor commands to change the vnc server like so: Start with: -vnc unix:test.socket,x509,tls Then use the following monitor command: change vnc unix:test.socket After this the pointer is still set but invalid and a crash can be triggered for instance by issuing the same command a second time which will try to object_unparent() the same pointer again. Signed-off-by: Wolfgang Bumiller Reviewed-by: Daniel P. Berrange Signed-off-by: Gerd Hoffmann --- ui/vnc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/vnc.c b/ui/vnc.c index 54673eb..c2d3773 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3134,6 +3134,7 @@ static void vnc_display_close(VncDisplay *vs) vs->subauth = VNC_AUTH_INVALID; if (vs->tlscreds) { object_unparent(OBJECT(vs->tlscreds)); + vs->tlscreds = NULL; } g_free(vs->tlsaclname); vs->tlsaclname = NULL;