qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: "Gonglei (Arei)" <arei.gonglei@huawei.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"dgilbert@redhat.com" <dgilbert@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] usb: fix up post load checks
Date: Tue, 13 May 2014 08:49:02 +0200	[thread overview]
Message-ID: <1399963742.7118.28.camel@nilsson.home.kraxel.org> (raw)
In-Reply-To: <33183CC9F5247A488A2544077AF19020815E7FA5@SZXEMA503-MBS.china.huawei.com>

On Di, 2014-05-13 at 03:02 +0000, Gonglei (Arei) wrote:
> Hi,
> 
> > -----Original Message-----
> > From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
> > [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
> > Behalf Of Michael S. Tsirkin
> > Sent: Monday, May 12, 2014 8:16 PM
> > To: qemu-devel@nongnu.org
> > Cc: Gerd Hoffmann; dgilbert@redhat.com
> > Subject: [Qemu-devel] [PATCH] usb: fix up post load checks
> > 
> > Correct post load checks:
> > 1. dev->setup_len == sizeof(dev->data_buf)
> >     seems fine, no need to fail migration
> > 2. When state is DATA, passing index > len
> >    will cause memcpy with negative length,
> >    resulting in heap overflow
> > 
> > First of the issues was reported by dgilbert.
> > 
> > Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  hw/usb/bus.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> > index e48b19f..2721719 100644
> > --- a/hw/usb/bus.c
> > +++ b/hw/usb/bus.c
> > @@ -51,8 +51,9 @@ static int usb_device_post_load(void *opaque, int
> > version_id)
> >      }
> >      if (dev->setup_index < 0 ||
> >          dev->setup_len < 0 ||
> > -        dev->setup_index >= sizeof(dev->data_buf) ||
> 
> Does this check should be deleted ?

It's ok, index <= len && len <= sizeof(buf) implies index <= sizeof(buf)

> 
> > -        dev->setup_len >= sizeof(dev->data_buf)) {
> > +        (dev->setup_state == SETUP_STATE_DATA &&
> > +         dev->setup_index > dev->setup_len) ||
> > +        dev->setup_len > sizeof(dev->data_buf)) {
> >          return -EINVAL;
> >      }
> >      return 0;
> > --
> > MST
> 
> Best regards,
> -Gonglei

  reply	other threads:[~2014-05-13  6:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12 12:16 [Qemu-devel] [PATCH] usb: fix up post load checks Michael S. Tsirkin
2014-05-13  3:02 ` Gonglei (Arei)
2014-05-13  6:49   ` Gerd Hoffmann [this message]
2014-05-13  7:50 ` Gerd Hoffmann
2014-05-13  8:32   ` Michael S. Tsirkin
2014-05-13  8:44     ` Gerd Hoffmann
2014-05-13  9:05       ` Michael S. Tsirkin
2014-05-13  9:49         ` Gerd Hoffmann
2014-05-14 13:16 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399963742.7118.28.camel@nilsson.home.kraxel.org \
    --to=kraxel@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).