From patchwork Tue Dec 3 16:28:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 296242 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6A49A2C0090 for ; Wed, 4 Dec 2013 03:31:28 +1100 (EST) Received: from localhost ([::1]:43418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vnssf-0003kv-Vn for incoming@patchwork.ozlabs.org; Tue, 03 Dec 2013 11:31:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vnsn2-00064N-Fw for qemu-devel@nongnu.org; Tue, 03 Dec 2013 11:25:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vnsmw-0006nl-HI for qemu-devel@nongnu.org; Tue, 03 Dec 2013 11:25:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60031) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vnsmw-0006nZ-9C; Tue, 03 Dec 2013 11:25:30 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB3GPRx4024287 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Dec 2013 11:25:28 -0500 Received: from redhat.com ([10.35.213.190]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id rB3GPPdC030750; Tue, 3 Dec 2013 11:25:26 -0500 Date: Tue, 3 Dec 2013 18:28:59 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1386087086-3691-15-git-send-email-mst@redhat.com> References: <1386087086-3691-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1386087086-3691-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-stable@nongnu.org, Michael Roth Subject: [Qemu-devel] [PATCH 14/23] openpic: avoid buffer overrun on incoming migration 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Michael Roth CVE-2013-4534 opp->nb_cpus is read from the wire and used to determine how many IRQDest elements to read into opp->dst[]. If the value exceeds the length of opp->dst[], MAX_CPU, opp->dst[] can be overrun with arbitrary data from the wire. Fix this by failing migration if the value read from the wire exceeds MAX_CPU. Signed-off-by: Michael Roth Signed-off-by: Michael S. Tsirkin --- hw/intc/openpic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c index 7df72f4..ab8c43d 100644 --- a/hw/intc/openpic.c +++ b/hw/intc/openpic.c @@ -1429,6 +1429,9 @@ static int openpic_load(QEMUFile* f, void *opaque, int version_id) qemu_get_be32s(f, &opp->tfrr); qemu_get_be32s(f, &opp->nb_cpus); + if (opp->nb_cpus > MAX_CPU) { + return -EINVAL; + } for (i = 0; i < opp->nb_cpus; i++) { qemu_get_sbe32s(f, &opp->dst[i].ctpr);