From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
rkrcmar@redhat.com, Dmitry Vyukov <dvyukov@google.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
stable@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] KVM: kvm_io_bus_unregister_dev() should never fail
Date: Thu, 23 Mar 2017 18:31:02 +0100 [thread overview]
Message-ID: <20170323183102.5f0f66e4.cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <20170323172419.21435-1-david@redhat.com>
On Thu, 23 Mar 2017 18:24:19 +0100
David Hildenbrand <david@redhat.com> wrote:
> No caller currently checks the return value of
> kvm_io_bus_unregister_dev(). This is evil, as all callers silently go on
> freeing their device. A stale reference will remain in the io_bus,
> getting at least used again, when the iobus gets teared down on
> kvm_destroy_vm() - leading to use after free errors.
>
> There is nothing the callers could do, except retrying over and over
> again.
>
> So let's simply remove the bus altogether, print an error and make
> sure no one can access this broken bus again (returning -ENOMEM on any
> attempt to access it).
>
> Fixes: e93f8a0f821e ("KVM: convert io_bus to SRCU")
> Cc: stable@vger.kernel.org # 3.4+
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>
> Based on kvm/queue, where we just got 2a108a4e7c1 ("KVM: x86: clear bus
> pointer when destroyed"), which added a check we need here.
>
> v1 -> v2:
> - added a check in kvm_destroy_vm()
> - added a check in virt/kvm/eventfd.c
>
> Using 'git grep -C 4 "kvm->buses"' should help to find all users. The other
> user in virt/kvm/eventfd.c should be fine.
>
> ---
> include/linux/kvm_host.h | 4 ++--
> virt/kvm/eventfd.c | 3 ++-
> virt/kvm/kvm_main.c | 42 +++++++++++++++++++++++++-----------------
> 3 files changed, 29 insertions(+), 20 deletions(-)
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
next prev parent reply other threads:[~2017-03-23 17:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-23 17:24 [PATCH v2] KVM: kvm_io_bus_unregister_dev() should never fail David Hildenbrand
2017-03-23 17:31 ` Cornelia Huck [this message]
2017-03-23 20:42 ` Marcelo Tosatti
2017-03-24 8:48 ` Dmitry Vyukov
2017-03-24 8:55 ` David Hildenbrand
2017-03-24 9:33 ` Cornelia Huck
2017-03-24 10:33 ` Marcelo Tosatti
2017-03-24 14:40 ` 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=20170323183102.5f0f66e4.cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=david@redhat.com \
--cc=dvyukov@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=stable@vger.kernel.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