From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUwhs-0005KZ-N0 for qemu-devel@nongnu.org; Tue, 01 Apr 2014 07:18:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUwhm-00034p-6k for qemu-devel@nongnu.org; Tue, 01 Apr 2014 07:18:16 -0400 Date: Tue, 1 Apr 2014 12:18:01 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20140401111800.GI2411@work-vm> References: <1396275242-10810-1-git-send-email-mst@redhat.com> <1396275242-10810-24-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-24-git-send-email-mst@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 23/30] zaurus: fix buffer overrun on invalid state load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: mdroth@linux.vnet.ibm.com, Stefan Weil , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Stefan Hajnoczi , Paolo Bonzini , =?us-ascii?B?PT9VVEYtOD9xP0FuZHJlYXM9MjBGPUMzPUE0cmJlcj89?= , dgilbert@redhat.com * Michael S. Tsirkin (mst@redhat.com) wrote: > CVE-2013-4540 > > Within scoop_gpio_handler_update, if prev_level has a high bit set, then > we get bit > 16 and that causes a buffer overrun. > > Since prev_level comes from wire indirectly, this can > happen on invalid state load. > > Similarly for gpio_level and gpio_dir. Reviewed-by: Dr. David Alan Gilbert (Without much understanding of the actual, apparently undocumented hardware) > To fix, limit to 16 bit. > > Reported-by: Michael S. Tsirkin > Signed-off-by: Michael S. Tsirkin > --- > hw/gpio/zaurus.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/hw/gpio/zaurus.c b/hw/gpio/zaurus.c > index dc79a8b..8e2ce04 100644 > --- a/hw/gpio/zaurus.c > +++ b/hw/gpio/zaurus.c > @@ -203,6 +203,15 @@ static bool is_version_0 (void *opaque, int version_id) > return version_id == 0; > } > > +static bool vmstate_scoop_validate(void *opaque, int version_id) > +{ > + ScoopInfo *s = opaque; > + > + return !(s->prev_level & 0xffff0000) && > + !(s->gpio_level & 0xffff0000) && > + !(s->gpio_dir & 0xffff0000); > +} > + > static const VMStateDescription vmstate_scoop_regs = { > .name = "scoop", > .version_id = 1, > @@ -215,6 +224,7 @@ static const VMStateDescription vmstate_scoop_regs = { > VMSTATE_UINT32(gpio_level, ScoopInfo), > VMSTATE_UINT32(gpio_dir, ScoopInfo), > VMSTATE_UINT32(prev_level, ScoopInfo), > + VMSTATE_VALIDATE("irq levels are 16 bit", vmstate_scoop_validate), > VMSTATE_UINT16(mcr, ScoopInfo), > VMSTATE_UINT16(cdr, ScoopInfo), > VMSTATE_UINT16(ccr, ScoopInfo), > -- > MST > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK