From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41459) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUd0e-0008Jw-VK for qemu-devel@nongnu.org; Mon, 31 Mar 2014 10:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUd0a-0000WI-5a for qemu-devel@nongnu.org; Mon, 31 Mar 2014 10:16:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUd0Z-0000W8-Sr for qemu-devel@nongnu.org; Mon, 31 Mar 2014 10:16:16 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s2VEGEl8015900 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 31 Mar 2014 10:16:15 -0400 Received: from redhat.com (vpn1-4-232.ams2.redhat.com [10.36.4.232]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id s2VEGCIP022271 for ; Mon, 31 Mar 2014 10:16:13 -0400 Date: Mon, 31 Mar 2014 17:16:42 +0300 From: "Michael S. Tsirkin" Message-ID: <1396275242-10810-12-git-send-email-mst@redhat.com> References: <1396275242-10810-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1396275242-10810-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PATCH v4 11/30] pl022: fix buffer overun on invalid state load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org CVE-2013-4530 pl022.c did not bounds check tx_fifo_head and rx_fifo_head after loading them from file and before they are used to dereference array. Reported-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ssi/pl022.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c index fd479ef..49b3f61 100644 --- a/hw/ssi/pl022.c +++ b/hw/ssi/pl022.c @@ -240,11 +240,23 @@ static const MemoryRegionOps pl022_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static int pl022_post_load(void *opaque, int version_id) +{ + PL022State *s = opaque; + + if (s->tx_fifo_head > ARRAY_SIZE(s->tx_fifo) || + s->rx_fifo_head > ARRAY_SIZE(s->rx_fifo)) { + return -1; + } + return 0; +} + static const VMStateDescription vmstate_pl022 = { .name = "pl022_ssp", .version_id = 1, .minimum_version_id = 1, .minimum_version_id_old = 1, + .post_load = pl022_post_load, .fields = (VMStateField[]) { VMSTATE_UINT32(cr0, PL022State), VMSTATE_UINT32(cr1, PL022State), -- MST