From patchwork Thu Apr 25 06:35:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 10916073 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 356FC1575 for ; Thu, 25 Apr 2019 06:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 203052882C for ; Thu, 25 Apr 2019 06:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F65B2887B; Thu, 25 Apr 2019 06:45:14 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 29FE92882C for ; Thu, 25 Apr 2019 06:45:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:52775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJY87-00067E-VP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 25 Apr 2019 02:45:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:60918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hJY6N-0004js-Q2 for qemu-devel@nongnu.org; Thu, 25 Apr 2019 02:43:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hJXyy-0004aj-L6 for qemu-devel@nongnu.org; Thu, 25 Apr 2019 02:35:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hJXyy-0004YT-Ez for qemu-devel@nongnu.org; Thu, 25 Apr 2019 02:35:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78585C057F3B; Thu, 25 Apr 2019 06:35:41 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-47.phx2.redhat.com [10.3.116.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 843055D9C5; Thu, 25 Apr 2019 06:35:37 +0000 (UTC) From: P J P To: QEMU Developers Date: Thu, 25 Apr 2019 12:05:34 +0530 Message-Id: <20190425063534.32747-1-ppandit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 25 Apr 2019 06:35:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qxl: check release info object 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: Bugs SysSec , Gerd Hoffmann , Prasad J Pandit Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Prasad J Pandit When releasing spice resources in release_resource() routine, if release info object 'ext.info' is null, it leads to null pointer dereference. Add check to avoid it. Reported-by: Bugs SysSec Signed-off-by: Prasad J Pandit --- hw/display/qxl.c | 3 +++ 1 file changed, 3 insertions(+) === (process:30785): Spice-WARNING **: 11:43:59.284: memslot.c:68:memslot_validate_virt: virtual address out of range virt=0x555556d247e0+0xbf slot_id=0 group_id=0 slot=0x0-0x0 delta=0x0 Thread 5 "SPICE Worker" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffdb7ff700 (LWP 30792)] interface_release_resource (sin=0x555556d12738, ext=...) at hw/display/qxl.c:785 785 QXLCommandExt *cmdext = (void *)(intptr_t)(ext.info->id); (gdb) bt #0 0x0000555555adca68 in interface_release_resource (sin=0x555556d12738, ext=...) at hw/display/qxl.c:785 #1 0x00007ffff74991d5 in red_drawable_unref (red_drawable=0x7fffd402a520) at red-worker.c:100 #2 0x00007ffff749941c in red_drawable_unref (red_drawable=) at red-worker.c:229 #3 0x00007ffff749941c in red_process_display (worker=worker@entry=0x555556e2f050, ring_is_empty=ring_is_empty@entry=0x7fffdb7fe854) at red-worker.c:229 #4 0x00007ffff74995f2 in worker_source_dispatch (source=, callback=, user_data=) at red-worker.c:1265 #5 0x00007ffff7ec906d in g_main_dispatch (context=0x555556e38fc0) at gmain.c:3182 #6 0x00007ffff7ec906d in g_main_context_dispatch (context=context@entry=0x555556e38fc0) at gmain.c:3847 #7 0x00007ffff7ec9438 in g_main_context_iterate (context=0x555556e38fc0, block=block@entry=1, dispatch=dispatch@entry=1, self=) at gmain.c:3920 #8 0x00007ffff7ec9762 in g_main_loop_run (loop=0x7fffd4002100) at gmain.c:4116 #9 0x00007ffff7498dde in red_worker_main (arg=0x555556e2f050) at red-worker.c:1369 #10 0x00007ffff70e458e in start_thread () at /lib64/libpthread.so.0 #11 0x00007ffff7013683 in clone () at /lib64/libc.so.6 (gdb) === diff --git a/hw/display/qxl.c b/hw/display/qxl.c index c8ce5781e0..632923add2 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -777,6 +777,9 @@ static void interface_release_resource(QXLInstance *sin, QXLReleaseRing *ring; uint64_t *item, id; + if (!ext.info) { + return; + } if (ext.group_id == MEMSLOT_GROUP_HOST) { /* host group -> vga mode update request */ QXLCommandExt *cmdext = (void *)(intptr_t)(ext.info->id);