From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUd1V-0001Oe-KK for qemu-devel@nongnu.org; Mon, 31 Mar 2014 10:17:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUd1Q-0000nV-IS for qemu-devel@nongnu.org; Mon, 31 Mar 2014 10:17:13 -0400 Date: Mon, 31 Mar 2014 17:17:19 +0300 From: "Michael S. Tsirkin" Message-ID: <1396275242-10810-23-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=iso-8859-1 Content-Disposition: inline In-Reply-To: <1396275242-10810-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v4 22/30] tsc210x: fix buffer overrun on invalid state load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , mdroth@linux.vnet.ibm.com, qemu-stable@nongnu.org, dgilbert@redhat.com, Alex Bligh , Paolo Bonzini , =?us-ascii?B?PT9VVEYtOD9xP0FuZHJlYXM9MjBGPUMzPUE0cmJlcj89?= CVE-2013-4539 s->precision, nextprecision, function and nextfunction come from wire and are used as idx into resolution[] in TSC_CUT_RESOLUTION. Validate after load to avoid buffer overrun. Cc: Andreas F=E4rber Signed-off-by: Michael S. Tsirkin --- hw/input/tsc210x.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c index 485c9e5..65a0d08 100644 --- a/hw/input/tsc210x.c +++ b/hw/input/tsc210x.c @@ -1070,9 +1070,21 @@ static int tsc210x_load(QEMUFile *f, void *opaque,= int version_id) s->enabled =3D qemu_get_byte(f); s->host_mode =3D qemu_get_byte(f); s->function =3D qemu_get_byte(f); + if (s->function > ARRAY_SIZE(mode_regs)) { + return -EINVAL; + } s->nextfunction =3D qemu_get_byte(f); + if (s->nextfunction < 0 || s->nextfunction >=3D ARRAY_SIZE(mode_regs= )) { + return -EINVAL; + } s->precision =3D qemu_get_byte(f); + if (s->precision < 0 || s->precision >=3D ARRAY_SIZE(resolution)) { + return -EINVAL; + } s->nextprecision =3D qemu_get_byte(f); + if (s->nextprecision < 0 || s->nextprecision >=3D ARRAY_SIZE(resolut= ion)) { + return -EINVAL; + } s->filter =3D qemu_get_byte(f); s->pin_func =3D qemu_get_byte(f); s->ref =3D qemu_get_byte(f); --=20 MST