From patchwork Thu Apr 3 16:52:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 336675 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 87C941400E0 for ; Fri, 4 Apr 2014 03:56:01 +1100 (EST) Received: from localhost ([::1]:45113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVkvm-0004lA-59 for incoming@patchwork.ozlabs.org; Thu, 03 Apr 2014 12:55:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVkrY-0006CB-PG for qemu-devel@nongnu.org; Thu, 03 Apr 2014 12:51:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVkrS-0005hL-KI for qemu-devel@nongnu.org; Thu, 03 Apr 2014 12:51:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVkrS-0005gr-3j; Thu, 03 Apr 2014 12:51:30 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s33GpO5J021128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 3 Apr 2014 12:51:25 -0400 Received: from redhat.com (vpn1-4-68.ams2.redhat.com [10.36.4.68]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id s33GpLtB004192; Thu, 3 Apr 2014 12:51:21 -0400 Date: Thu, 3 Apr 2014 19:52:01 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1396543778-22307-18-git-send-email-mst@redhat.com> References: <1396543778-22307-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1396543778-22307-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Peter Maydell , Peter Crosthwaite , mdroth@linux.vnet.ibm.com, qemu-stable@nongnu.org, dgilbert@redhat.com, =?us-ascii?B?PT9VVEYtOD9xP0FuZHJlYXM9MjBGPUMzPUE0cmJlcj89?= Subject: [Qemu-devel] [PATCH v5 17/24] ssi-sd: fix buffer overrun on invalid state load 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 CVE-2013-4537 s->arglen is taken from wire and used as idx in ssi_sd_transfer(). Validate it before access. Signed-off-by: Michael S. Tsirkin --- hw/sd/ssi-sd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index 3273c8a..2fa2b2b 100644 --- a/hw/sd/ssi-sd.c +++ b/hw/sd/ssi-sd.c @@ -230,6 +230,14 @@ static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id) for (i = 0; i < 5; i++) s->response[i] = qemu_get_be32(f); s->arglen = qemu_get_be32(f); + if (s->mode == SSI_SD_CMDARG && + (s->arglen < 0 || s->arglen > ARRAY_SIZE(s->cmdarg))) { + return -EINVAL; + } + if (s->mode == SSI_SD_RESPONSE && + (s->response_pos < 0 || s->response_pos > ARRAY_SIZE(s->response))) { + return -EINVAL; + } s->response_pos = qemu_get_be32(f); s->stopping = qemu_get_be32(f);