From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, P J P <ppandit@redhat.com>,
Qemu Developers <qemu-devel@nongnu.org>,
"Daniel P . Berrange" <berrange@redhat.com>,
Cyrille Chatras <cyrille.chatras@orange.com>,
Prasad J Pandit <pjp@fedoraproject.org>
Subject: Re: [Qemu-devel] [PATCH v1] ps2: check PS2Queue pointers in post_load routine
Date: Tue, 21 Nov 2017 13:18:13 +0000 [thread overview]
Message-ID: <20171121131812.GC2434@work-vm> (raw)
In-Reply-To: <20171117093556.ntseydf7eiboeyww@sirius.home.kraxel.org>
* Gerd Hoffmann (kraxel@redhat.com) wrote:
> > > diff --git a/hw/input/ps2.c b/hw/input/ps2.c
> > > index f388a23c8e..de171a28dd 100644
> > > --- a/hw/input/ps2.c
> > > +++ b/hw/input/ps2.c
> > > @@ -1225,24 +1225,21 @@ static void ps2_common_reset(PS2State *s)
> > > static void ps2_common_post_load(PS2State *s)
> > > {
> > > PS2Queue *q = &s->queue;
> > > - int size;
> > > - int i;
> > > - int tmp_data[PS2_QUEUE_SIZE];
> > > + uint8_t i, size;
> > > + uint8_t tmp_data[PS2_QUEUE_SIZE];
> >
> > Hi Prasad,
> >
> > you don't need to change the invalid values to sane ones. Instead, make
> > ps2_common_post_load return an int (just like the .post_load member of
> > VMStateDescription). You can then detect out of range count/rptr/wptr
> > and return -1 for bad indices.
>
> Well, it's not that simple because older qemu versions had larger
> queues. So post_load accepts migrations with queues which are too big.
> It just clears the queue in that case, so the input events are dropped
> in that (highly unlikely) case.
>
> Also note that the current post_load is broken. tmp_data is int whereas
> q->data is uint8_t. So ...
>
> > > - memcpy(q->data, tmp_data, size);
>
> ... this memcpy doesn't work as intended. Nobody noticed in years.
Oops!
> v1 fixes this bug, v2 doesn't.
>
> So, I'm tempted to just rip out the whole backward compatibility buffer
> shuffling logic. Or take v1 of this patch.
I think v1 is OK.
Dave
> cheers,
> Gerd
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-11-21 13:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-16 7:51 [Qemu-devel] [PATCH v1] ps2: check PS2Queue pointers in post_load routine P J P
2017-11-16 9:10 ` Paolo Bonzini
2017-11-16 10:19 ` P J P
2017-11-17 9:35 ` Gerd Hoffmann
2017-11-21 13:18 ` Dr. David Alan Gilbert [this message]
2018-01-25 15:19 ` Gerd Hoffmann
2018-01-31 7:15 ` P J P
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=20171121131812.GC2434@work-vm \
--to=dgilbert@redhat.com \
--cc=berrange@redhat.com \
--cc=cyrille.chatras@orange.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=ppandit@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.