From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhPXg-0007Eo-IV for qemu-devel@nongnu.org; Mon, 05 May 2014 16:31:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhPXb-0000wy-LQ for qemu-devel@nongnu.org; Mon, 05 May 2014 16:31:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhPXb-0000wq-Cn for qemu-devel@nongnu.org; Mon, 05 May 2014 16:31:11 -0400 From: Juan Quintela Date: Mon, 5 May 2014 22:30:14 +0200 Message-Id: <1399321834-31310-17-git-send-email-quintela@redhat.com> In-Reply-To: <1399321834-31310-1-git-send-email-quintela@redhat.com> References: <1399321834-31310-1-git-send-email-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 16/36] 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: =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Michael S. Tsirkin" From: "Michael S. Tsirkin" 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=C3=A4rber Signed-off-by: Michael S. Tsirkin Signed-off-by: Juan Quintela --- 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 1.9.0