From patchwork Tue Nov 1 12:37:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9407319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA27460234 for ; Tue, 1 Nov 2016 12:38:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC39B29861 for ; Tue, 1 Nov 2016 12:38:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF1F129864; Tue, 1 Nov 2016 12:38:31 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 1BD6D29861 for ; Tue, 1 Nov 2016 12:38:30 +0000 (UTC) Received: from localhost ([::1]:47588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1YKj-0000Qo-CV for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Nov 2016 08:38:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1YKU-0000Qj-2E for qemu-devel@nongnu.org; Tue, 01 Nov 2016 08:38:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1YKQ-00008X-50 for qemu-devel@nongnu.org; Tue, 01 Nov 2016 08:38:14 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:34905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1YKP-00007t-UM for qemu-devel@nongnu.org; Tue, 01 Nov 2016 08:38:10 -0400 Received: by mail-wm0-x241.google.com with SMTP id 68so15825330wmz.2 for ; Tue, 01 Nov 2016 05:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=PZYv4GyzF/TsY/raMIO3eGJKis/j3lbhfdU6HXuc+z0=; b=rOzxEoLExFz67s0TKaVWbdA2EEdGoB5CNwzsjkx0kVJAamRPF2S1CHV20chdscp5Wc 2X5gBP0dFcFcIAQMXLN7Egwxa4Fpw2adXyqNY4LNH2ehWG2vb3oW3qY3kxga+K92LuQj Ne25FklMcqmUJ52wSwfEb28p3pHfsw5GlGE/LEMcT8eeAZ/C4rWY69pXmvo1EAWEd/Jw nw+6zfx4mN47n7WVueE/F2JxicOZWgKptnuyHiC1r7yWWZ5sDm4IQY871BIMqyEgzvKt bpXA4IusaLV+JxUOcF3/tJ7Hx+pd3b5CIkSK0wMnh6rQje47DwVxzmG/mjZOR02lG7Qr 1F7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=PZYv4GyzF/TsY/raMIO3eGJKis/j3lbhfdU6HXuc+z0=; b=d0TLlBYieh/jDJ7NEI3JIrepvsP5740rErfFdnwqaVv0L35fsVGzMbVSsKOD4XvmsA caf3zzkIfKMF2MY2ZnbDntzRuczfJjqSsJUKn4LoHQ6K54BgfUy3JqmmJfH9NOtt4icD EK6GYFmd+qLpwGL1QcPFeEjE/9v6Zof4goCbpX+oqb7yNvcz6bOkrT7WDT5ZrW7zKHBE E8Uhevh7wgt02DkhryokEz7/BXl5iwha5nIdQQSyUemKdhLTd3fFA1mXay6f5QGzAfgf RnGiKx2QJmtjlTh83RR1sj5iErAs1BdZCtWkGNGLkjo+EOXyNk+ZHsocFpe/kv8GpbWu SF8Q== X-Gm-Message-State: ABUngvecx3f0RCuZzEk+v9Zj3Q35J9glHdeD2gWO1lUmL/3eHPc2jBSfsKZt0r0CIkBsgA== X-Received: by 10.194.235.34 with SMTP id uj2mr25117941wjc.144.1478003887268; Tue, 01 Nov 2016 05:38:07 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id hy10sm27754099wjb.10.2016.11.01.05.38.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Nov 2016 05:38:06 -0700 (PDT) Message-ID: <58188cae.4a6ec20a.3d2d1.aff2@mx.google.com> X-Google-Original-Message-ID: <1478003877-6500-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: kraxel@redhat.com, qemu-devel@nongnu.org Date: Tue, 1 Nov 2016 05:37:57 -0700 X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH] virtio-gpu: fix information leak in capset get dispatch 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: Li Qiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Li Qiang In virgl_cmd_get_capset function, it uses g_malloc to allocate a response struct to the guest. As the 'resp'struct hasn't been full initialized it will lead the 'resp->padding' field to the guest. Use g_malloc0 to avoid this. Signed-off-by: Li Qiang Reviewed-by: Marc-André Lureau --- hw/display/virtio-gpu-3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c index 23f39de..d98b140 100644 --- a/hw/display/virtio-gpu-3d.c +++ b/hw/display/virtio-gpu-3d.c @@ -371,7 +371,7 @@ static void virgl_cmd_get_capset(VirtIOGPU *g, virgl_renderer_get_cap_set(gc.capset_id, &max_ver, &max_size); - resp = g_malloc(sizeof(*resp) + max_size); + resp = g_malloc0(sizeof(*resp) + max_size); resp->hdr.type = VIRTIO_GPU_RESP_OK_CAPSET; virgl_renderer_fill_caps(gc.capset_id,