From: Jason Wang <jasowang@redhat.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: mst@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com,
peterx@redhat.com
Subject: Re: [Qemu-devel] [PATCH] virtio: destroy region cache during reset
Date: Wed, 8 Mar 2017 17:51:22 +0800 [thread overview]
Message-ID: <64df071f-27b0-9ee6-0b76-d8fa7a9cc8ec@redhat.com> (raw)
In-Reply-To: <20170308101922.730b1579.cornelia.huck@de.ibm.com>
On 2017年03月08日 17:19, Cornelia Huck wrote:
> On Wed, 8 Mar 2017 11:18:27 +0800
> Jason Wang <jasowang@redhat.com> wrote:
>
>> On 2017年03月07日 18:16, Cornelia Huck wrote:
>>> On Tue, 7 Mar 2017 16:47:58 +0800
>>> Jason Wang <jasowang@redhat.com> wrote:
>>>
>>>> We don't destroy region cache during reset which can make the maps
>>>> of previous driver leaked to a buggy or malicious driver that don't
>>>> set vring address before starting to use the device. Fix this by
>>>> destroy the region cache during reset and validate it before trying to
>>>> use them. While at it, also validate address_space_cache_init() during
>>>> virtio_init_region_cache() to make sure we have a correct region
>>>> cache.
>>>>
>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>> ---
>>>> hw/virtio/virtio.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++--------
>>>> 1 file changed, 76 insertions(+), 12 deletions(-)
>>>> @@ -190,6 +211,10 @@ static inline uint16_t vring_avail_flags(VirtQueue *vq)
>>>> {
>>>> VRingMemoryRegionCaches *caches = atomic_rcu_read(&vq->vring.caches);
>>>> hwaddr pa = offsetof(VRingAvail, flags);
>>>> + if (!caches) {
>>>> + virtio_error(vq->vdev, "Cannot map avail flags");
>>> I'm not sure that virtio_error is the right thing here; ending up in
>>> this function with !caches indicates an error in our logic.
>> Probably not, this can be triggered by buggy guest.
> I would think that even a buggy guest should not be able to trigger
> accesses to vring structures that have not yet been set up. What am I
> missing?
I think this may happen if a driver start the device without setting the
vring address. In this case, region caches cache the mapping of previous
driver. But maybe I was wrong.
>
>>> An assert
>>> might be better (and I hope we can sort out all of those errors exposed
>>> by the introduction of region caches for 2.9...)
>> I thought we should avoid assert as much as possible in this case. But
>> if you and maintainer want an assert, it's also fine.
> My personal rule-of-thumb:
> - If it is something that can be triggered by the guest, or it is
> something that is easily recovered, set the device to broken.
> - If it is something that indicates that we messed up our internal
> logic, use an assert.
>
> I think arriving here with !caches indicates the second case; but if
> there is a way for a guest to trigger this, setting the device to
> broken would certainly be better.
Yes, broken seems better.
Thanks
next prev parent reply other threads:[~2017-03-08 9:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-07 8:47 [Qemu-devel] [PATCH] virtio: destroy region cache during reset Jason Wang
2017-03-07 10:16 ` Cornelia Huck
2017-03-08 3:18 ` Jason Wang
2017-03-08 9:19 ` Cornelia Huck
2017-03-08 9:51 ` Jason Wang [this message]
2017-03-08 10:12 ` Cornelia Huck
2017-03-09 2:19 ` Jason Wang
2017-03-09 11:07 ` Cornelia Huck
2017-03-09 11:12 ` Paolo Bonzini
2017-03-09 11:38 ` Cornelia Huck
2017-03-10 10:57 ` Jason Wang
2017-03-07 10:55 ` Paolo Bonzini
2017-03-08 3:21 ` Jason Wang
2017-03-08 6:22 ` Jason Wang
2017-03-08 9:10 ` Paolo Bonzini
2017-03-08 9:48 ` Jason Wang
2017-03-09 11:10 ` Paolo Bonzini
2017-03-09 11:49 ` Cornelia Huck
2017-03-08 9:30 ` Cornelia Huck
2017-03-08 9:53 ` Jason Wang
2017-03-08 10:15 ` Cornelia Huck
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=64df071f-27b0-9ee6-0b76-d8fa7a9cc8ec@redhat.com \
--to=jasowang@redhat.com \
--cc=cornelia.huck@de.ibm.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@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).