From mboxrd@z Thu Jan 1 00:00:00 1970 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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 673A7C0650E for ; Wed, 3 Jul 2019 09:08:32 +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 4035F20828 for ; Wed, 3 Jul 2019 09:08:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4035F20828 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hibFf-0007RO-IG for qemu-devel@archiver.kernel.org; Wed, 03 Jul 2019 05:08:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55173) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hib2T-0004EB-4r for qemu-devel@nongnu.org; Wed, 03 Jul 2019 04:54:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hib2S-0003yq-5c for qemu-devel@nongnu.org; Wed, 03 Jul 2019 04:54:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42746) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hib2P-00030G-2I; Wed, 03 Jul 2019 04:54:49 -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 9536A3081244; Wed, 3 Jul 2019 08:54:24 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-96.ams2.redhat.com [10.36.116.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 653E7891D2; Wed, 3 Jul 2019 08:54:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6E76B1747C; Wed, 3 Jul 2019 10:54:16 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 3 Jul 2019 10:54:14 +0200 Message-Id: <20190703085416.21837-3-kraxel@redhat.com> In-Reply-To: <20190703085416.21837-1-kraxel@redhat.com> References: <20190703085416.21837-1-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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.49]); Wed, 03 Jul 2019 08:54:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PULL 2/4] virtio-gpu: check if the resource already exists in virtio_gpu_load() 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: Peter Maydell , "Michael S. Tsirkin" , Li Qiang , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Li Qiang While loading virtio-gpu, the data can be malicious, we should check if the resource already exists. Signed-off-by: Li Qiang Reviewed-by: Marc-Andr=C3=A9 Lureau Message-id: 20190628161358.10400-1-liq3ea@163.com Signed-off-by: Gerd Hoffmann --- hw/display/virtio-gpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 475a018c027c..25d9e327fc69 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1002,6 +1002,11 @@ static int virtio_gpu_load(QEMUFile *f, void *opaq= ue, size_t size, =20 resource_id =3D qemu_get_be32(f); while (resource_id !=3D 0) { + res =3D virtio_gpu_find_resource(g, resource_id); + if (res) { + return -EINVAL; + } + res =3D g_new0(struct virtio_gpu_simple_resource, 1); res->resource_id =3D resource_id; res->width =3D qemu_get_be32(f); --=20 2.18.1