From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVkrk-0006Tq-3l for qemu-devel@nongnu.org; Thu, 03 Apr 2014 12:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVkre-0005mM-Ju for qemu-devel@nongnu.org; Thu, 03 Apr 2014 12:51:47 -0400 Date: Thu, 3 Apr 2014 19:52:09 +0300 From: "Michael S. Tsirkin" Message-ID: <1396543778-22307-20-git-send-email-mst@redhat.com> References: <1396543778-22307-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: <1396543778-22307-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v5 19/24] 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 , mdroth@linux.vnet.ibm.com, Stefan Hajnoczi , 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..aa5b688 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 < 0 || s->function >=3D 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