From patchwork Wed May 5 04:58:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239081 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F38C43460 for ; Wed, 5 May 2021 05:15:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EC82613C1 for ; Wed, 5 May 2021 05:15:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EC82613C1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9sr-0007RM-IW for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:15:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9rc-00067n-Hq for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:24 -0400 Received: from m12-16.163.com ([220.181.12.16]:58169) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rY-00017G-Fw for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=zlCFF 1m7rXQZjXsw0wpx6URXzl2KvVLjDHEWjVRKgC4=; b=a6M5PbwU0Mk3EgYMM3QWG sDascPIvCFTIcjTOOaho7D6BdsGrd23PQ5ky9bFTZXOpk9MKr7Xp6QkFLI7vrcjZ DcIoEBzfQQM1pjg+ot0vBe/UNM/OfXzWkSd6HCZ+MJjIBXMyXMHzsfkXMaO+Ili7 MV4N3ogf36QNiIRw+4mfbk= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S5; Wed, 05 May 2021 12:58:29 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 1/7] vhost-user-gpu: fix memory disclosure in virgl_cmd_get_capset_info Date: Tue, 4 May 2021 21:58:18 -0700 Message-Id: <20210505045824.33880-2-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S5 X-Coremail-Antispam: 1Uf129KBjvdXoW5Kry3Cw17Ar1DGF18Xr4fXwb_yoWxWFb_ZF 1FyFn7AF4DWrW0krs8Zw4rJ3yavrWYyFsayFnakr1xXFyYkw15Xwn3t34kJ3yfuw43GF4D AFy0yw4rGa1j9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUboGQPUUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbB8QWJbV2MZ6UWWQAAsM Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Otherwise some of the 'resp' will be leaked to guest. Signed-off-by: Li Qiang --- contrib/vhost-user-gpu/virgl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 9e6660c7ab..6a332d601f 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -128,6 +128,7 @@ virgl_cmd_get_capset_info(VuGpu *g, VUGPU_FILL_CMD(info); + memset(&resp, 0, sizeof(resp)); if (info.capset_index == 0) { resp.capset_id = VIRTIO_GPU_CAPSET_VIRGL; virgl_renderer_get_cap_set(resp.capset_id, From patchwork Wed May 5 04:58:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB25CC433B4 for ; Wed, 5 May 2021 05:15:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12B5A60FE9 for ; Wed, 5 May 2021 05:15:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12B5A60FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9sp-0007MI-S2 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:15:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9rb-00067G-D5 for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:23 -0400 Received: from m12-16.163.com ([220.181.12.16]:57537) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rW-00010J-LM for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=yjGgd yEI4yFRIsPij/wQlBf/XfQxp/AuLx+xqGJnJNo=; b=nplPebjSgbqFz4QsZqWX0 P3mDH9LUq7HCWpx+eqrKxlhnLyxM9Cm/0nbkxE0rDJcje0PsMyx0Mv6UsV8IoO4P gUzDkBmfaQ/WnrbKcLerIR13WKfTuayJQFXJ6xAnZZHEzFkbz4ybShvdoCV6lf/l UJ8MwC62AT8eqOY0C9Bg30= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S6; Wed, 05 May 2021 12:58:31 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 2/7] vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' Date: Tue, 4 May 2021 21:58:19 -0700 Message-Id: <20210505045824.33880-3-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S6 X-Coremail-Antispam: 1Uf129KBjvdXoWruFW5Ary7tFy3Xr4UKryDZFb_yoW3XFb_Za 18AF4kCFsxWFy09w4Dtws8A3yayFW3Jr4xtFy0kF15CFyUtwnIqwn5tryktrW8Zw4DKFn8 ArWUJw48ZF12vjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU84xR3UUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBZhaJbVaD7t4NYgABsf Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_20=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Call 'vugbm_buffer_destroy' in error path to avoid resource leak. Signed-off-by: Li Qiang Reviewed-by: Prasad J Pandit --- contrib/vhost-user-gpu/vhost-user-gpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c index f73f292c9f..b5e153d0d6 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -349,6 +349,7 @@ vg_resource_create_2d(VuGpu *g, g_critical("%s: resource creation failed %d %d %d", __func__, c2d.resource_id, c2d.width, c2d.height); g_free(res); + vugbm_buffer_destroy(&res->buffer); cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; return; } From patchwork Wed May 5 04:58:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9198C433B4 for ; Wed, 5 May 2021 05:18:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6CF9E613C3 for ; Wed, 5 May 2021 05:18:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6CF9E613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9vN-0002Am-GF for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:18:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9rb-000678-Cw for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:23 -0400 Received: from m12-16.163.com ([220.181.12.16]:58179) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rX-00017P-2Q for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=qhxdp 2+XuUwqK1mWfkicveCMIiNuA0bJoCb2FPc385Y=; b=ODwI643R+Ft663ETr1TMm OEQvmEWZgpDpb4KeDxWb3Q/OryA5/7gKiutyDuBV/oZdWJDrKJuLJ2NfAuizDkue o9iYiOH+PAfzwJYRRB/vwqFcNuuByl814uWxCRguC+KnOnCUV1Ycdh8pBblox6vK uYkjRnQryKdqgDrFn/WLYA= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S7; Wed, 05 May 2021 12:58:32 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 3/7] vhost-user-gpu: fix memory leak in vg_resource_attach_backing Date: Tue, 4 May 2021 21:58:20 -0700 Message-Id: <20210505045824.33880-4-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S7 X-Coremail-Antispam: 1Uf129KBjvdXoWruFWrKF17Xw4kuFyfXry7Wrg_yoW3Gwc_Za 1rAFs7CwsxWFyv9F4jqw15ZryayFW3Jr1xJF92kry3WFyFqwnIqw1Fyryktr48Zw4DCF1D ArWUJr48Gr12vjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8E38UUUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbB8QiJbV2MZ6UWcQAAsp Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_40=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Check whether the 'res' has already been attach_backing to avoid memory leak. Signed-off-by: Li Qiang --- contrib/vhost-user-gpu/vhost-user-gpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c index b5e153d0d6..0437e52b64 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -489,6 +489,11 @@ vg_resource_attach_backing(VuGpu *g, return; } + if (res->iov) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + ret = vg_create_mapping_iov(g, &ab, cmd, &res->iov); if (ret != 0) { cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; From patchwork Wed May 5 04:58:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48E03C433B4 for ; Wed, 5 May 2021 05:20:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E31516139A for ; Wed, 5 May 2021 05:20:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E31516139A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9xc-0004mh-SY for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:20:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9rb-00067K-HI for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:23 -0400 Received: from m12-16.163.com ([220.181.12.16]:58171) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rX-00017J-L7 for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=+GwqY ZPzmbVi5RTWr/I6FZUle2cqOpVXUMn+p8zEDDQ=; b=EwSpxJdRWcC2kob10pKoN xPiiPYyOhYp8d1O7OrslaaVketqH2kz9Wh8mwVBiSKPbMQdmu9ISyQL2QfJv3hAf 1nRhkksWw6ooVSuDD2U6tSVJnx5OhnJmL1zrz8lYNixjyOAULqyNxsAv7yPtr60J dg01knTayMMpLF+RPS4I/o= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S8; Wed, 05 May 2021 12:58:33 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 4/7] vhost-user-gpu: fix memory link while calling 'vg_resource_unref' Date: Tue, 4 May 2021 21:58:21 -0700 Message-Id: <20210505045824.33880-5-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S8 X-Coremail-Antispam: 1Uf129KBjvdXoWrtry3AF1rtw1rury7GFWUXFb_yoW3Krg_Za 1rAF4kArsxWry09w4Utw13A3yayFW3Jr1xGF92kFy5KryrKwnYqw1Sqr97tryUZw4DuF1D CryUJw4rWr1Y9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbPxhJUUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiTxmJbVsGYnBXkQAAs7 Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If the guest trigger following sequences, the attach_backing will be leaked: vg_resource_create_2d vg_resource_attach_backing vg_resource_unref This patch fix this by freeing 'res->iov' in vg_resource_destroy. Signed-off-by: Li Qiang Reviewed-by: Prasad J Pandit --- contrib/vhost-user-gpu/vhost-user-gpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c index 0437e52b64..770dfad529 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -400,6 +400,7 @@ vg_resource_destroy(VuGpu *g, } vugbm_buffer_destroy(&res->buffer); + g_free(res->iov); pixman_image_unref(res->image); QTAILQ_REMOVE(&g->reslist, res, next); g_free(res); From patchwork Wed May 5 04:58:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239079 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF261C433ED for ; Wed, 5 May 2021 05:15:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A0DD60FE9 for ; Wed, 5 May 2021 05:15:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A0DD60FE9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9sr-0007Rt-IO for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:15:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9rd-00068h-E9 for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:25 -0400 Received: from m12-16.163.com ([220.181.12.16]:58168) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rX-00017F-L6 for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=P1b/7 n0WfNJIVr+gBpZKF2Ry0uGkFvSi0n+ot3liv28=; b=CmqRQRkvzKbgoYYqziLDJ ++ouCz7IpDnAc0wq0k2y0VPrVnk0rvmsk1zb5xr6ca4gcKMrRtOFeZKjSRCoLVJJ YonxzxG+w1KRRmDt0FHg+IQ7Dp7eKKpOURJ2CnBLbqZp2NO/b0IkUpOinEtDdbRR TKrznLRlvKUAdvfd9YG9eY= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S9; Wed, 05 May 2021 12:58:34 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 5/7] vhost-user-gpu: fix memory leak in 'virgl_cmd_resource_unref' Date: Tue, 4 May 2021 21:58:22 -0700 Message-Id: <20210505045824.33880-6-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S9 X-Coremail-Antispam: 1Uf129KBjvdXoW7Wr1DXF1UGFW3WF1rtFy3twb_yoWftrX_ZF 4YkF1kAr15GFy09ay5Zw1rAayay34S9FyvvFyfKa4rKFy5ur1qqw18X34kGry29r4DGF4D XryFyw4rCw43ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbTmh7UUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbCCgqJbV2Ma3VztQAAst Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The 'res->iov' will be leaked if the guest trigger following sequences: virgl_cmd_create_resource_2d virgl_resource_attach_backing virgl_cmd_resource_unref This patch fixes this. Signed-off-by: Li Qiang --- contrib/vhost-user-gpu/virgl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 6a332d601f..c669d73a1d 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -108,9 +108,16 @@ virgl_cmd_resource_unref(VuGpu *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_unref unref; + struct iovec *res_iovs = NULL; + int num_iovs = 0; VUGPU_FILL_CMD(unref); + virgl_renderer_resource_detach_iov(unref.resource_id, + &res_iovs, + &num_iovs); + g_free(res_iovs); + virgl_renderer_resource_unref(unref.resource_id); } From patchwork Wed May 5 04:58:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFC86C433ED for ; Wed, 5 May 2021 05:18:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98694613C3 for ; Wed, 5 May 2021 05:18:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98694613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9vO-0002FA-O9 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:18:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9ri-0006Iu-Pw for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:30 -0400 Received: from m12-16.163.com ([220.181.12.16]:58932) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rg-0001G5-9t for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=VB6Lx 2qoSlaoSWWnEIymTr6B23IGQf/fSdRoCCDV7Zg=; b=kr6LST3Y8HNLGj+JxibT7 PkalJHP3KvSIxCSVMYPY+v7DJFqKYzIzz+lGWxflv7t5UhOgx5ovWBlnb19NiVvd Y3L/UqJSCdSxGI3SxeN447j3UmbnKTyS8sHqKZ3s7kghDzhucYd3gtO4oQ2Q4psf gjlcXw3babFWDA4xxSzykU= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S10; Wed, 05 May 2021 12:58:35 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 6/7] vhost-user-gpu: fix memory leak in 'virgl_resource_attach_backing' Date: Tue, 4 May 2021 21:58:23 -0700 Message-Id: <20210505045824.33880-7-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S10 X-Coremail-Antispam: 1Uf129KBjvdXoW7GFy7ZrW5AF17XFWfXFWDurg_yoW3Xrb_ZF 4FkFn7Ar1UWFyj9wsxXw1rCayayrWrZF97GF97Ka4fCFyYgw15Jw1rJ3s7J3429w1DWFnr Zryvyw4rCa13ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbZa9DUUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiKRuJbVXl0Y5R3gAAs2 Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If 'virgl_renderer_resource_attach_iov' failed, the 'res_iovs' will be leaked. Signed-off-by: Li Qiang --- contrib/vhost-user-gpu/virgl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index c669d73a1d..a16a311d80 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -287,8 +287,11 @@ virgl_resource_attach_backing(VuGpu *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, res_iovs, att_rb.nr_entries); + if (ret != 0) { + g_free(res_iovs); + } } static void From patchwork Wed May 5 04:58:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93243C43461 for ; Wed, 5 May 2021 05:18:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D0C0613C3 for ; Wed, 5 May 2021 05:18:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D0C0613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9vP-0002Fx-93 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:18:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9rc-00067t-On for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:24 -0400 Received: from m12-16.163.com ([220.181.12.16]:58178) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rX-00017O-L7 for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=QTmgs OcfkOmjLcbwZwmklrqfoD9/5A+DbgbSLcgxKAA=; b=jbEwGxjBlg+JeRWbJRAFT /CrhZHyuWNTD8S618/cwFADwy9gaPSsyDdvn10XuIy0d69H9xcdEEYLyO04VkKXC WFoCnhnljsRhwU7VD9UGutG4QNNrw6eYyuL6h0mbU1JuFXQEvgduLwrw6zTtou0h +G6L0Jm45dGYDv7Ce68vlY= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S11; Wed, 05 May 2021 12:58:36 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 7/7] vhost-user-gpu: fix OOB write in 'virgl_cmd_get_capset' Date: Tue, 4 May 2021 21:58:24 -0700 Message-Id: <20210505045824.33880-8-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S11 X-Coremail-Antispam: 1Uf129KBjvdXoWrtw43Ww1fXF1kAF1ktr17trb_yoW3Kwc_XF 4Skrn3Ar4DXryq9Fs8Arn0vrW7ArWUA3Z2vFyfKw1fXFyak3WUXw1fG3s5GrW3Z3ykuF1D A340yw4rWF4q9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUUOJ57UUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiTxyJbVsGYnBXtgAAsZ Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If 'virgl_cmd_get_capset' set 'max_size' to 0, the 'virgl_renderer_fill_caps' will write the data after the 'resp'. This patch avoid this by checking the returned 'max_size'. Signed-off-by: Li Qiang Reviewed-by: Prasad J Pandit --- contrib/vhost-user-gpu/virgl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index a16a311d80..7172104b19 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -177,6 +177,10 @@ virgl_cmd_get_capset(VuGpu *g, virgl_renderer_get_cap_set(gc.capset_id, &max_ver, &max_size); + if (!max_size) { + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; + return; + } resp = g_malloc0(sizeof(*resp) + max_size); resp->hdr.type = VIRTIO_GPU_RESP_OK_CAPSET;